﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
                    xmlns:converters="clr-namespace:UBCon.Ribbon.Converters"
                    xmlns:effect="clr-namespace:UBCon.Resources.Effects;assembly=UBCon.Resources"
                    xmlns:enums="clr-namespace:UBCon.Core.Enums;assembly=UBCon.Core"
                    xmlns:res="clr-namespace:UBCon.Resources;assembly=UBCon.Resources"
                    xmlns:resSkin="clr-namespace:UBCon.Resources.SkinManagers;assembly=UBCon.Resources"
                    xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
                    xmlns:skin="clr-namespace:UBCon.Ribbon.SkinManagers"
                    xmlns:ubcr="clr-namespace:UBCon.Ribbon">

    <BooleanToVisibilityConverter x:Key="BooleanConverter" />

    <converters:FalseToVisibilityConverter x:Key="falseToVisibilityConverter" />

    <converters:ActualWidthConverter x:Key="widthConverter" />

    <ControlTemplate x:Key="ContextMenuTemplate" TargetType="{x:Type ContextMenu}">
        <Grid>
            <Border Name="Border"
                    Margin="7"
                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=WhiteBrush}}"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=DropDownBorderBrush}}"
                    BorderThickness="1"
                    Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                               ResourceId=DropDownShadowEffect}}" />
            <StackPanel Margin="8"
                        IsItemsHost="True"
                        KeyboardNavigation.DirectionalNavigation="Cycle" />
        </Grid>

    </ControlTemplate>

    <Style x:Key="DefaultContextMenuStyle" TargetType="{x:Type ContextMenu}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Grid.IsSharedSizeScope" Value="true" />
        <Setter Property="Template" Value="{StaticResource ResourceKey=ContextMenuTemplate}" />
    </Style>

    <ContextMenu x:Key="DefaultContextMenu"
                 x:Shared="True"
                 Style="{StaticResource ResourceKey=DefaultContextMenuStyle}">
        <ubcr:DropDownMenuItem Header="{x:Static res:LocalizationResources.AddToQAToolbarText}" />
        <ubcr:DropDownMenuItem Header="{x:Static res:LocalizationResources.QAToolbarSettingsText}" />
        <ubcr:DropDownMenuItem Header="{x:Static res:LocalizationResources.PlaceQAunderRibbonBarText}" />
        <ubcr:DropDownMenuItem Header="{x:Static res:LocalizationResources.MinimizeRibbonBarText}" />
    </ContextMenu>

    <!--  ================================RibbonChrome Template And Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonChrome}, ResourceId=RibbonChromeTemplate}" TargetType="{x:Type ubcr:RibbonChrome}">
        <Grid x:Name="PART_Root" Height="{TemplateBinding Height}">
            <Border x:Name="PART_DefaultButton"
                    Margin="0"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}" />
            <Border x:Name="PART_HoverButton"
                    Margin="0"
                    Background="{TemplateBinding MouseOverBackgroundBrush}"
                    BorderBrush="{TemplateBinding MouseOverBorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Focusable="False"
                    Opacity="0" />
            <Border x:Name="PART_PressedButton"
                    Margin="0"
                    Background="{TemplateBinding PressedBackgroundBrush}"
                    BorderBrush="{TemplateBinding PressedBorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Focusable="False"
                    Opacity="0" />
            <ContentPresenter Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Content="{TemplateBinding Content}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="RenderMouseOver" Value="True">
                <Setter TargetName="PART_DefaultButton" Property="Opacity" Value="0" />
                <Setter TargetName="PART_PressedButton" Property="Opacity" Value="0" />
                <Setter TargetName="PART_HoverButton" Property="Opacity" Value="1" />
            </Trigger>
            <Trigger Property="RenderPressed" Value="True">
                <Setter TargetName="PART_DefaultButton" Property="Opacity" Value="0" />
                <Setter TargetName="PART_HoverButton" Property="Opacity" Value="0" />
                <Setter TargetName="PART_PressedButton" Property="Opacity" Value="1" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonChrome}" TargetType="{x:Type ubcr:RibbonChrome}">
        <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}" />
        <Setter Property="InnerBorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="MouseOverBorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBorderBrush}}" />
        <Setter Property="MouseOverBackgroundBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
        <Setter Property="PressedBorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBorderBrush}}" />
        <Setter Property="PressedBackgroundBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="InnerBorderThickness" Value="0" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="InnerBorderCornerRadius" Value="0" />
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonChrome}, ResourceId=RibbonChromeTemplate}}" />
    </Style>

    <!--  ================================TwoLineText Template And Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TwoLineText}, ResourceId=TwoLineTextTemplate}" TargetType="{x:Type ubcr:TwoLineText}">
        <Grid x:Name="PART_TwoLineTextRoot">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="PART_TwoLineText1"
                       Grid.ColumnSpan="2"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Text="{Binding Path=Text1,
                                      RelativeSource={RelativeSource Mode=TemplatedParent},
                                      Mode=TwoWay}"
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            <TextBlock x:Name="PART_TwoLineText2"
                       Grid.Row="1"
                       VerticalAlignment="Center"
                       Text="{Binding Path=Text2,
                                      RelativeSource={RelativeSource Mode=TemplatedParent},
                                      Mode=TwoWay}"
                       TextAlignment="Right" 
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            <Image x:Name="PART_TwoLineTextImage"
                   Grid.Row="1"
                   Grid.Column="1"
                   Width="6"
                   Height="3"
                   Margin="4,0,0,-2"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   RenderOptions.BitmapScalingMode="HighQuality"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=ExpandImage}}"
                   Stretch="Fill"
                   Visibility="{TemplateBinding ImageVisibility}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Text2" Value="{x:Null}">
                <Setter TargetName="PART_TwoLineTextImage" Property="Margin" Value="3,0,0,6" />
                <Setter TargetName="PART_TwoLineTextImage" Property="Grid.Column" Value="0" />
                <Setter TargetName="PART_TwoLineTextImage" Property="Grid.ColumnSpan" Value="2" />
                <Setter TargetName="PART_TwoLineTextImage" Property="HorizontalAlignment" Value="Center" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:TwoLineText}" TargetType="{x:Type ubcr:TwoLineText}">
        <Setter Property="Template" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TwoLineText}, ResourceId=TwoLineTextTemplate}}" />
    </Style>

    <!--  ================================RibbonButton Template And Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonButton}, ResourceId=SmallRibbonButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           HorizontalContentAlignment="Left"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Grid Width="{TemplateBinding Width}" Focusable="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Image x:Name="image"
                       Grid.Column="0"
                       Width="16"
                       Height="16"
                       Margin="4, 0, 0, 0"
                       HorizontalAlignment="Center"
                       Focusable="False"
                       RenderOptions.BitmapScalingMode="Linear"
                       RenderOptions.EdgeMode="Aliased"
                       Source="{TemplateBinding Image}"
                       Stretch="Fill" />
                <TextBlock x:Name="content"
                           Grid.Column="1"
                           Margin="3, 0, 4, 0"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Focusable="False"
                           FontSize="11"
                           Padding="1,0,1,0"
                           Text="{Binding Path=Title,
                                          RelativeSource={RelativeSource Mode=TemplatedParent}}"
                           TextAlignment="Center"
                           TextTrimming="CharacterEllipsis"
                           TextWrapping="NoWrap" 
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Grid>
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="Title" Value="{x:Null}">
                <Setter Property="Width" Value="24" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonButton}, ResourceId=LargeRibbonButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Grid Margin="4,0,4,0" Focusable="False">
                <Grid.RowDefinitions>
                    <RowDefinition x:Name="row1" />
                    <RowDefinition x:Name="row2" />
                </Grid.RowDefinitions>
                <Image x:Name="image"
                       Width="32"
                       Height="32"
                       Margin="0,0.5,0,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Focusable="False"
                       RenderOptions.BitmapScalingMode="Linear"
                       Source="{TemplateBinding Image}" />
                <ubcr:TwoLineText x:Name="text"
                                  Grid.Row="1"
                                  Margin="3, 0, 5, 0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Top"
                                  Focusable="False"
                                  FontSize="11"
                                  ImageVisibility="Collapsed"
                                  Text="{TemplateBinding Title}" />
            </Grid>
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonButton}" TargetType="{x:Type ubcr:RibbonButton}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Style.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonButton}, ResourceId=SmallRibbonButtonTemplate}}" />
                <Setter Property="Height" Value="23" />
            </Trigger>
            <Trigger Property="Size" Value="Large">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonButton}, ResourceId=LargeRibbonButtonTemplate}}" />
                <Setter Property="Height" Value="69" />
                <Setter Property="Width" Value="Auto" />
            </Trigger>
            <Trigger Property="HasContent" Value="True">
                <Setter Property="Width" Value="Auto" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
                <Setter Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================ControlTemplates and Styles for Window buttons==============================================  -->

    <!--  Minimize button template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=DefaultCaptioButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=TransparentBrush}}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Rectangle x:Name="MinimizeButton_Content"
                       Width="9"
                       Height="2"
                       Margin="0, 5.5, 0, 0"
                       HorizontalAlignment="Center"
                       Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                ResourceId=DefaultImageBrush}}"
                       RenderOptions.BitmapScalingMode="Linear" />
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="MinimizeButton_Content" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="MinimizeButton_Content" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--  Maximize button template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly=ubcr:RibbonWindow, ResourceId=MaximizeButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           Background="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                             ResourceId=TransparentBrush}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Grid RenderOptions.EdgeMode="Aliased">
                <Path x:Name="MaximizeButton_Path1"
                      Data="M0,0L9,0 9,9 0,9 0,0z"
                      Stretch="None"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                 ResourceId=DefaultImageBrush}}"
                      StrokeEndLineCap="Flat"
                      StrokeStartLineCap="Flat"
                      StrokeThickness="1" />
                <Path x:Name="MaximizeButton_Path2"
                      Data="M0,1L9,1"
                      Stretch="None"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                 ResourceId=DefaultImageBrush}}"
                      StrokeEndLineCap="Flat"
                      StrokeStartLineCap="Flat"
                      StrokeThickness="2" />
            </Grid>
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="MaximizeButton_Path1" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
                <Setter TargetName="MaximizeButton_Path2" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="MaximizeButton_Path1" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
                <Setter TargetName="MaximizeButton_Path2" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--  Restore button template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=RestoreButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           Background="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                             ResourceId=TransparentBrush}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Grid RenderOptions.EdgeMode="Aliased">
                <Path x:Name="RestoreButton_Path1"
                      Data="M0,3L6,3 6,8 0,8 0,4z  M3,2 L3,0L9,0L9,5L7,5"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                 ResourceId=DefaultImageBrush}}"
                      StrokeEndLineCap="Flat"
                      StrokeStartLineCap="Flat"
                      StrokeThickness="1" />
                <Path x:Name="RestoreButton_Path2"
                      ClipToBounds="True"
                      Data="M0,4L6,4 M3,1L9,1"
                      Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                 ResourceId=DefaultImageBrush}}"
                      StrokeEndLineCap="Flat"
                      StrokeStartLineCap="Flat"
                      StrokeThickness="2" />
            </Grid>

        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="RestoreButton_Path1" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
                <Setter TargetName="RestoreButton_Path2" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DecoratorBrush}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="RestoreButton_Path1" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
                <Setter TargetName="RestoreButton_Path2" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CaptionButtonPressedStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--  Close button template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=CloseButtonTemplate}" TargetType="{x:Type ubcr:RibbonButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=TransparentBrush}}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <Image x:Name="CloseButton_Image"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=NormalStateImage}}"
                   Stretch="None" />
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="CloseButton_Image" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverStateImage}}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="CloseButton_Image" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedStateImage}}" />
            </Trigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--  Minimize button style  -->
    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=DefaultCaptioButtonStyle}" TargetType="{x:Type ubcr:RibbonButton}">
        <Setter Property="Width" Value="28" />
        <Setter Property="Height" Value="25" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="RenderOptions.EdgeMode" Value="Aliased" />
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=DefaultCaptioButtonTemplate}}" />
    </Style>

    <!--  Maximize button style  -->
    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                        ResourceId=MaximizeButtonStyle}"
           BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                      ResourceId=DefaultCaptioButtonStyle}}"
           TargetType="{x:Type ubcr:RibbonButton}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=MaximizeButtonTemplate}}" />
    </Style>

    <!--  Restore button style  -->
    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                        ResourceId=RestoreButtonStyle}"
           BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                      ResourceId=DefaultCaptioButtonStyle}}"
           TargetType="{x:Type ubcr:RibbonButton}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=ubcr:RibbonWindow, ResourceId=RestoreButtonTemplate}}" />
    </Style>

    <!--  Close button style  -->
    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                        ResourceId=CloseButtonStyle}"
           BasedOn="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                      ResourceId=DefaultCaptioButtonStyle}}"
           TargetType="{x:Type ubcr:RibbonButton}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=CloseButtonTemplate}}" />
    </Style>

    <!--  Options button template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowOptionsButtonTemplate}" TargetType="{x:Type ubcr:RibbonDropDownButton}">
        <Grid>
            <ToggleButton Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          ClickMode="{TemplateBinding ClickMode}"
                          Command="{TemplateBinding Command}"
                          CommandParameter="{TemplateBinding CommandParameter}"
                          CommandTarget="{TemplateBinding CommandTarget}"
                          FocusVisualStyle="{x:Null}"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                                           Background="{TemplateBinding Background}"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <Image x:Name="image"
                                   Grid.Column="0"
                                   Width="{Binding Path=(ubcr:RibbonHelper.ImageWidth),
                                                   Mode=OneWay,
                                                   RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                  AncestorType={x:Type ubcr:RibbonDropDownButton}}}"
                                   Height="{Binding Path=(ubcr:RibbonHelper.ImageHeight),
                                                    Mode=OneWay,
                                                    RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                   AncestorType={x:Type ubcr:RibbonDropDownButton}}}"
                                   Margin="2, 0, 3, 0"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   RenderOptions.BitmapScalingMode="Linear"
                                   Source="{Binding Path=Image,
                                                    RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                   AncestorType={x:Type ubcr:RibbonDropDownButton}},
                                                    Mode=OneWay,
                                                    NotifyOnSourceUpdated=True}"
                                   Stretch="Fill" />
                        </ubcr:RibbonChrome>

                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="{Binding Path=DropDownPlacement,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       Mode=OneWay,
                                       NotifyOnSourceUpdated=True}"
                   PlacementTarget="{Binding Path=PlacementTarget,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Mode=OneWay,
                                             NotifyOnSourceUpdated=True}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <StackPanel x:Name="PART_DropDownButtonItemsHost"
                                    Margin="1"
                                    FocusVisualStyle="{x:Null}"
                                    Focusable="True"
                                    IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                    </Grid>
                </Border>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Image" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarOptionsButtonImage_MouseOverState}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Thickness x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBorderThickness}">1</Thickness>

    <!--  ================================RibbonWindow Template And Style==============================================  -->

    <Thickness x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=ButtonsPanelMargin}">0,0,0,0</Thickness>

    <Visibility x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=ApplicationIconVisibility}">Visible</Visibility>

    <Thickness x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=QAToolbarMargin}">25,0,0,0</Thickness>

    <!--  Classic template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=ClassicWindowTemplate}" TargetType="{x:Type ubcr:RibbonWindow}">
        <Border Margin="{Binding Path=WindowResizeFrame,
                                 RelativeSource={RelativeSource Mode=TemplatedParent},
                                 NotifyOnSourceUpdated=True}"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}">
            <Grid x:Name="PART_RootPanel">
                <Grid x:Name="PART_TitlePanel"
                      Margin="{Binding Path=TitleBarMargin,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       NotifyOnSourceUpdated=True}"
                      VerticalAlignment="Top">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition x:Name="imageColumn" Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Canvas x:Name="PART_ContextualHeaderPanel" Grid.ColumnSpan="3">
                        <TextBlock x:Name="PART_TitleText"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   RenderTransformOrigin="0.5,0.5"
                                   Text="{TemplateBinding Title}"
                                   TextAlignment="Left"
                                   TextTrimming="CharacterEllipsis" 
                                   Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                    </Canvas>

                    <Image x:Name="PART_Icon"
                           Width="17"
                           Height="17"
                           Margin="0, 0, 5, 0"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center"
                           shell:WindowChrome.IsHitTestVisibleInChrome="True"
                           RenderOptions.BitmapScalingMode="HighQuality"
                           Source="{TemplateBinding Icon}"
                           Stretch="Fill"
                           Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                          ResourceId=ApplicationIconVisibility}}" />
                    <ContentPresenter x:Name="PART_QAToolbarHost"
                                      Grid.Column="1"
                                      HorizontalAlignment="Left"
                                      ContentSource="QAToolbar" />

                    <Rectangle x:Name="PART_TitleLocator"
                               Grid.Column="2"
                               Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=TransparentBrush}}"
                               Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=TransparentBrush}}" />
                </Grid>
                <ContentPresenter x:Name="PART_AppMenuPresenter"
                                  Panel.ZIndex="0"
                                  ContentSource="ApplicationMenu"
                                  Opacity="0"
                                  Visibility="Collapsed" />
                <AdornerDecorator x:Name="PART_ContentAdorner">
                    <ContentPresenter Content="{TemplateBinding Content}"
                                      ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                      ContentTemplate="{TemplateBinding ContentTemplate}" />
                </AdornerDecorator>
                <ResizeGrip x:Name="WindowResizeGrip"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Bottom"
                            IsTabStop="False"
                            Visibility="Collapsed" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
                    <Condition Property="WindowState" Value="Normal" />
                </MultiTrigger.Conditions>
                <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible" />
            </MultiTrigger>

            <DataTrigger Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True">
                <Setter TargetName="PART_AppMenuPresenter" Property="Opacity" Value="1" />
                <Setter TargetName="PART_AppMenuPresenter" Property="Visibility" Value="Visible" />
            </DataTrigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="PART_QAToolbarHost" Property="Margin" Value="3,0,0,0" />
                <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsApplicationMenuOpen, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True" />
                    <Condition Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="False" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="PART_ContextualHeaderPanel" Property="Opacity" Value="0" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Panel.ZIndex" Value="1" />
                    <Setter TargetName="PART_ContentAdorner" Property="Panel.ZIndex" Value="0" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Visibility" Value="Visible" />
                    <Setter TargetName="PART_ContentAdorner" Property="Visibility" Value="Collapsed" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Opacity" Value="1" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!--  Ribbon template  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=DefaultRibbonWindowTemplate}" TargetType="{x:Type ubcr:RibbonWindow}">
        <Border x:Name="PART_OuterBorder"
                Margin="0"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                CornerRadius="0"
                Grid.IsSharedSizeScope="True"
                IsHitTestVisible="True">
            <Grid x:Name="PART_RootPanel">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition x:Name="imageColumn" Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition x:Name="titleRow" Height="29" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Border x:Name="PART_CaptionBorder"
                        Grid.ColumnSpan="4"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=WindowActiveTitleBrush}}" />
                <Canvas x:Name="PART_ContextualHeaderPanel" Grid.ColumnSpan="4">
                    <TextBlock x:Name="PART_TitleText"
                               Canvas.Top="5"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               RenderTransformOrigin="0.5,0.5"
                               Text="{TemplateBinding Title}"
                               TextAlignment="Left"
                               TextTrimming="CharacterEllipsis" 
                               Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                </Canvas>

                <Image x:Name="PART_Icon"
                       Width="17"
                       Height="17"
                       Margin="5, 0, 5, 0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       shell:WindowChrome.IsHitTestVisibleInChrome="True"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       Source="{TemplateBinding Icon}"
                       Stretch="Fill"
                       Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                      ResourceId=ApplicationIconVisibility}}" />

                <Button x:Name="PART_HideButton"
                        Grid.ColumnSpan="3"
                        Height="23"
                        VerticalAlignment="Top"
                        Visibility="Collapsed">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <ubcr:RibbonChrome HorizontalContentAlignment="Right"
                                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                              ResourceId=TransparentBrush}}"
                                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                               ResourceId=TransparentBrush}}"
                                               CornerRadius="0"
                                               RenderMouseOver="{TemplateBinding IsMouseOver}"
                                               RenderPressed="{TemplateBinding IsPressed}">
                                <Grid Margin="0,0,10,0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition />
                                        <ColumnDefinition />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Ellipse Grid.Column="0"
                                             Width="3"
                                             Height="3"
                                             Margin="1.5,0"
                                             Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=RibbonWindowBorderBrush}}" />
                                    <Ellipse Grid.Column="1"
                                             Width="3"
                                             Height="3"
                                             Margin="1.5,0"
                                             Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=RibbonWindowBorderBrush}}" />
                                    <Ellipse Grid.Column="2"
                                             Width="3"
                                             Height="3"
                                             Margin="1.5,0"
                                             Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=RibbonWindowBorderBrush}}" />
                                </Grid>
                            </ubcr:RibbonChrome>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <ContentPresenter x:Name="PART_QAToolbarHost"
                                  Grid.Column="1"
                                  HorizontalAlignment="Left"
                                  ContentSource="QAToolbar" />

                <Rectangle x:Name="PART_TitleLocator"
                           Grid.Column="2"
                           Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=TransparentBrush}}"
                           Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                      ResourceId=TransparentBrush}}" />
                <StackPanel x:Name="PART_CaptionButtonsHolder"
                            Grid.Column="3"
                            Margin="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                       ResourceId=ButtonsPanelMargin}}"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Panel.ZIndex="2"
                            Orientation="Horizontal">
                    <ubcr:RibbonButton x:Name="MinimizeButton"
                                       Command="{x:Static ubcr:RibbonWindow.MinimizeCommand}"
                                       Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                                 ResourceId=DefaultCaptioButtonStyle}}"
                                       Visibility="{Binding Path=IsMinimizeButtonEnabled,
                                                            RelativeSource={RelativeSource Mode=TemplatedParent},
                                                            Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    <ubcr:RibbonButton x:Name="MaximizeButton"
                                       Command="{x:Static ubcr:RibbonWindow.MaximizeCommand}"
                                       Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                                 ResourceId=MaximizeButtonStyle}}"
                                       Visibility="{Binding Path=IsMinimizeButtonEnabled,
                                                            RelativeSource={RelativeSource Mode=TemplatedParent},
                                                            Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    <ubcr:RibbonButton x:Name="CloseButton"
                                       Command="{x:Static ubcr:RibbonWindow.CloseCommand}"
                                       Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow},
                                                                                                 ResourceId=CloseButtonStyle}}"
                                       Visibility="{Binding Path=IsCloseButtonEnabled,
                                                            RelativeSource={RelativeSource Mode=TemplatedParent},
                                                            Converter={StaticResource ResourceKey=BooleanConverter}}" />

                </StackPanel>
                <StackPanel x:Name="PART_HiddenItemsPanel"
                            Grid.Column="3"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Panel.ZIndex="2"
                            Orientation="Horizontal"
                            Visibility="Collapsed">
                    <ubcr:RibbonButton Command="{x:Static ubcr:RibbonWindow.CloseCommand}" Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=CloseButtonStyle}}" />
                </StackPanel>

                <ContentPresenter x:Name="PART_AppMenuPresenter"
                                  Grid.Row="1"
                                  Grid.RowSpan="3"
                                  Grid.ColumnSpan="4"
                                  Panel.ZIndex="0"
                                  ContentSource="ApplicationMenu"
                                  Opacity="0"
                                  Visibility="Collapsed" />

                <AdornerDecorator x:Name="PART_ContentAdorner"
                                  Grid.Row="3"
                                  Grid.ColumnSpan="4"
                                  Panel.ZIndex="1">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ContentPresenter ContentSource="Content" />
                        <ContentPresenter x:Name="PART_Footer"
                                          Grid.Row="1"
                                          ContentSource="Footer" />
                    </Grid>
                </AdornerDecorator>

            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <!--<Trigger Property="Visibility" Value="Visible" SourceName="Office2007Button">
                <Setter Property="AppicationMenu.MenuStyle" Value="Office2007"/>
            </Trigger>-->
            <!--<DataTrigger Binding="{Binding Path=ApplicationMenu.MenuStyle, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}"
                         Value="Office2007">
                <Setter Property="Margin" Value="20,0,0,0" TargetName="PART_QAToolbarHost"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Icon"/>
            </DataTrigger>-->
            <!--<MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=QAToolbar.IsAboveRibbon, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="False"/>
                    <Condition Binding="{Binding Path=ApplicationMenu.MenuStyle, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}"
                         Value="Office2007"/>
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Margin" Value="0" TargetName="PART_QAToolbarHost"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>-->


            <DataTrigger Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True">
                <Setter TargetName="PART_AppMenuPresenter" Property="Opacity" Value="1" />
                <Setter TargetName="PART_AppMenuPresenter" Property="Visibility" Value="Visible" />
            </DataTrigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="PART_QAToolbarHost" Property="Margin" Value="3,0,0,0" />
                <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <Trigger Property="Mode" Value="AutoHideMode">
                <Setter TargetName="titleRow" Property="Height" Value="23" />
                <Setter TargetName="PART_HideButton" Property="Visibility" Value="Visible" />
                <Setter TargetName="PART_HiddenItemsPanel" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="WindowState" Value="Maximized">

                <Setter TargetName="MaximizeButton" Property="Style" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=RestoreButtonStyle}}" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsApplicationMenuOpen, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True" />
                    <Condition Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="False" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="PART_ContextualHeaderPanel" Property="Opacity" Value="0" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Panel.ZIndex" Value="1" />
                    <Setter TargetName="PART_ContentAdorner" Property="Panel.ZIndex" Value="0" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Visibility" Value="Visible" />
                    <Setter TargetName="PART_ContentAdorner" Property="Visibility" Value="Collapsed" />
                    <Setter TargetName="PART_AppMenuPresenter" Property="Opacity" Value="1" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>

            <Trigger Property="IsActive" Value="False">
                <Setter TargetName="PART_CaptionBorder" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowInActiveTitleBrush}}" />
            </Trigger>
            <Trigger Property="WindowStyle" Value="ToolWindow">
                <Setter TargetName="MinimizeButton" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="MaximizeButton" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonWindow}" TargetType="{x:Type ubcr:RibbonWindow}">
        <Style.Triggers>
            <Trigger Property="Theme" Value="Default">
                <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBackgroundBrush}}" />
                <Setter Property="BorderThickness" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBorderThickness}}" />
                <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" />
                <Setter Property="Template" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=DefaultRibbonWindowTemplate}}" />
            </Trigger>
            <Trigger Property="Theme" Value="Classic">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
                <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
                <Setter Property="Template" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonWindow}, ResourceId=ClassicWindowTemplate}}" />
            </Trigger>
        </Style.Triggers>

    </Style>


    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=FlatRepeatButton}" TargetType="{x:Type RepeatButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="1"
                           Content="{TemplateBinding Content}"
                           CornerRadius="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="1"
                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=SideScrollerMouseOverBoderBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=SideScrollerPressedBoderBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}" />
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonScrollViewer}, ResourceId=SidedScrollViewerTemplate}" TargetType="{x:Type ScrollViewer}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <RepeatButton Width="{Binding Path=(ubcr:ScrollViewerHelper.ButtonWidth),
                                          RelativeSource={RelativeSource Mode=TemplatedParent},
                                          Mode=OneWay}"
                          Height="{TemplateBinding ActualHeight}"
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=GrayBrush}}"
                          Command="ScrollBar.LineLeftCommand"
                          Delay="10"
                          Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar},
                                                                                      ResourceId=FlatRepeatButton}}"
                          Visibility="{Binding Path=(ubcr:ScrollViewerHelper.CanLineLeft),
                                               RelativeSource={RelativeSource Mode=TemplatedParent},
                                               Converter={StaticResource ResourceKey=BooleanConverter}}">
                <Image Width="3"
                       Height="5"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=LeftArrow}}"
                       Stretch="Fill" />
            </RepeatButton>
            <ScrollContentPresenter Grid.Column="1"
                                    CanContentScroll="{TemplateBinding CanContentScroll}"
                                    Content="{TemplateBinding Content}" />
            <RepeatButton Grid.Column="2"
                          Width="{Binding Path=(ubcr:ScrollViewerHelper.ButtonWidth),
                                          RelativeSource={RelativeSource Mode=TemplatedParent},
                                          Mode=OneWay}"
                          Height="{TemplateBinding ActualHeight}"
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=GrayBrush}}"
                          Command="ScrollBar.LineRightCommand"
                          Delay="10"
                          Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar},
                                                                                      ResourceId=FlatRepeatButton}}"
                          Visibility="{Binding Path=(ubcr:ScrollViewerHelper.CanLineRight),
                                               RelativeSource={RelativeSource Mode=TemplatedParent},
                                               Converter={StaticResource ResourceKey=BooleanConverter}}">
                <Image Width="3"
                       Height="5"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=RightArrow}}"
                       Stretch="Fill" />
            </RepeatButton>
        </Grid>
    </ControlTemplate>

    <!--  ================================RibbonBar Template And Style==============================================  -->

    <GridLength x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TabItemsRowHeight}">25</GridLength>

    <CornerRadius x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=RibbonBarCornerRadius}">0</CornerRadius>

    <Thickness x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=ShowOnlyTabMargin}">0</Thickness>

    <!--  ApplicationMenu button templates  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultAppMenuButtonTemplate}" TargetType="{x:Type ToggleButton}">
        <ubcr:RibbonChrome Background="{TemplateBinding Background}"
                           Content="{TemplateBinding Content}"
                           CornerRadius="0"
                           Foreground="{TemplateBinding Foreground}"
                           InnerBorderCornerRadius="0"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=SelectedMenuBackgroundBrush}}"
                           Padding="{TemplateBinding Padding}"
                           PressedBackgroundBrush="{Binding Path=Background,
                                                            RelativeSource={RelativeSource Mode=Self}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}" />
    </ControlTemplate>

    <!--<ControlTemplate TargetType="{x:Type ToggleButton}" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=Office2007MenuButton}">
        <Grid Width="37"
              Height="37">
            <Ellipse Fill="#A0000000"
                     Margin="1,1,0,0"
                     Width="36"
                     Height="36"
                     HorizontalAlignment="Left"/>
            <Ellipse x:Name="elipse"
                     StrokeThickness="0"
                     Stroke="#FFE0E0FF"
                     Width="36" Height="36" HorizontalAlignment="Left"
                     Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SilverButton}}" />
            <Ellipse x:Name="mouseOver"
                     StrokeThickness="0"
                     Stroke="#FFE0E0FF"
                     Width="36"
                     Height="36"
                     HorizontalAlignment="Left"
                     Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OrangeLightButton}}"
                     Opacity="0" />
            <Path Stroke="{x:Null}"
                  StrokeThickness="0"
                  Stretch="None"
                  Data="M0,18 A 18,18 180 0,1 36,18 L 36,18 A 12,27 90 0,0 0,18">
                <Path.Fill>
                    <RadialGradientBrush GradientOrigin="0.5,0.10"
                                         RadiusX="1">
                        <GradientStop Color="#F0FFFFFF" Offset="0" />
                        <GradientStop Color="#20FFFFFF" Offset="0.5" />
                        <GradientStop Color="#40FFFFFF" Offset="1" />
                    </RadialGradientBrush>
                </Path.Fill>
            </Path>
            <Ellipse StrokeThickness="1.5"
                     Stroke="#94FFFFFF"
                     Width="36"
                     Height="36"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Top" />
            <ContentPresenter HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              ContentSource="Content"
                              Panel.ZIndex="15"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation To="1"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="mouseOver"
                                    Duration="0:0:0.10" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation To="0"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="mouseOver"
                                             Duration="0:0:0.25" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Fill"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OrangeButton}}"
                        TargetName="elipse" />
                <Setter Property="Visibility"
                        Value="Hidden"
                        TargetName="mouseOver" />
            </Trigger>
            <Trigger Property="IsChecked"
                     Value="True">
                <Setter Property="Fill"
                        Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=OrangeButton}}"
                        TargetName="elipse" />
                <Setter Property="Visibility"
                        Value="Hidden"
                        TargetName="mouseOver" />
            </Trigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>-->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=DefaultRibbonBarTemplate}" TargetType="{x:Type ubcr:RibbonBar}">
        <Grid x:Name="PART_Root">
            <Grid x:Name="PART_RootGrid" Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarBackgroundBrush}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TabItemsRowHeight}}" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <!-- <ContentPresenter Content="{TemplateBinding ApplicationMenu}" />-->
                <ToggleButton x:Name="PART_RibbonBarAppMenu"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                             ResourceId=AppMenuBackgroundBrush}}"
                              Command="{Binding Path=OpenCloseAppMenuCommand,
                                                RelativeSource={RelativeSource Mode=FindAncestor,
                                                                               AncestorType={x:Type ubcr:RibbonWindow}}}"
                              CommandParameter="True"
                              Padding="{Binding Path=ApplicationMenu.Padding,
                                                RelativeSource={RelativeSource Mode=TemplatedParent},
                                                Mode=OneWay}"
                              Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DefaultAppMenuButtonTemplate}}">
                    <TextBlock x:Name="textContent"
                               Foreground="{Binding Path=ApplicationMenu.Foreground,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Mode=OneWay}"
                               Text="{Binding Path=ApplicationMenu.Title,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=OneWay}" />
                </ToggleButton>

                <Canvas x:Name="PART_ContextualHiddenPanel"
                        Grid.ColumnSpan="4"
                        Focusable="False"
                        Visibility="Collapsed" />

                <ScrollViewer Grid.Column="1"
                              Grid.ColumnSpan="3"
                              Margin="2,0,0,0"
                              Panel.ZIndex="2"
                              ubcr:ScrollViewerHelper.Attach="True"
                              ubcr:ScrollViewerHelper.ButtonWidth="15"
                              CanContentScroll="True"
                              Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonScrollViewer},
                                                                                          ResourceId=SidedScrollViewerTemplate}}">
                    <ubcr:RibbonTabItemPanel x:Name="PART_RibbonBarRootPanel"
                                             AnimatedScroll="False"
                                             FocusVisualStyle="{x:Null}"
                                             IsItemsHost="True"
                                             Orientation="Horizontal" />
                </ScrollViewer>
                <Border x:Name="PART_ItemsHolder"
                        Grid.Row="1"
                        Grid.ColumnSpan="3"
                        Height="95"
                        Margin="0,-1.3,0,0"
                        VerticalAlignment="Top"
                        Panel.ZIndex="1"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=RibbonBarSelectedItemBkBrush}}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar},
                                                                                         ResourceId=RibbonBarCornerRadius}}"
                        Focusable="False">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="35" />
                        </Grid.ColumnDefinitions>
                        <ItemsControl ItemsSource="{Binding Path=SelectedItem.Items, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}">
                            <ItemsControl.Template>
                                <ControlTemplate TargetType="{x:Type ItemsControl}">
                                    <ScrollViewer ubcr:ScrollViewerHelper.Attach="True"
                                                  CanContentScroll="True"
                                                  Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonScrollViewer},
                                                                                                              ResourceId=SidedScrollViewerTemplate}}">
                                        <ubcr:RibbonStackPanel AnimatedScroll="False"
                                                               FitsToViewport="True"
                                                               IsItemsHost="True"
                                                               Orientation="Horizontal" />
                                    </ScrollViewer>
                                </ControlTemplate>
                            </ItemsControl.Template>
                        </ItemsControl>
                        <!--<Canvas Grid.ColumnSpan="3"
                                Panel.ZIndex="5"
                                Visibility="Collapsed"
                                x:Name="hiddenCanvas"
                                Grid.RowSpan="2">
                            <Rectangle x:Name="PART_HiddenRect"
                                       Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarSelectedItemBkBrush}}"
                                       Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarSelectedItemBkBrush}}"
                                       Height="1"
                                       Grid.Row="0"/>
                        </Canvas>-->
                    </Grid>
                </Border>

            </Grid>
            <Popup AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                    Mode=TwoWay}"
                   Placement="Bottom"
                   PlacementTarget="{Binding ElementName=PART_RibbonBarAppMenu}"
                   PopupAnimation="None"
                   StaysOpen="False">
                <ContentPresenter x:Name="PART_HiddenCP" Panel.ZIndex="1" />
            </Popup>
            <Popup x:Name="PART_AutoHidePopup"
                   AllowsTransparency="True"
                   HorizontalOffset="0"
                   Placement="AbsolutePoint"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="0">
                <Grid x:Name="PART_RootAutoHideGrid" Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WindowBackgroundBrush}}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid x:Name="PART_AutoHideGrid">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                    </Grid>
                    <ContentPresenter x:Name="PART_HiddenBarCP" Grid.Row="1" />
                </Grid>
            </Popup>
            <Popup x:Name="PART_DropDownMenuPopup"
                   AllowsTransparency="True"
                   Placement="Bottom"
                   PlacementTarget="{Binding ElementName=PART_RibbonBarAppMenu}"
                   PopupAnimation="Fade"
                   StaysOpen="False" />
        </Grid>
        <ControlTemplate.Triggers>

            <!--<DataTrigger Binding="{Binding Path=ApplicationMenu.MenuStyle, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}"
                         Value="Classic">
                <Setter Property="Panel.ZIndex" Value="10" TargetName="PART_RibbonBarAppMenu"/>
                <Setter Property="Visibility" Value="Visible" TargetName="imageContent"/>
                <Setter Property="Visibility" Value="Collapsed" TargetName="textContent"/>
                <Setter Property="VerticalOffset" Value="-8" TargetName="PART_DropDownMenuPopup" />
            </DataTrigger>-->

            <DataTrigger Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="True">
                <Setter TargetName="PART_DropDownMenuPopup" Property="IsOpen" Value="{Binding Path=ApplicationMenu.IsApplicationMenuOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}" />

                <Setter TargetName="PART_RibbonBarAppMenu" Property="Command" Value="{x:Null}" />
                <Setter TargetName="PART_RibbonBarAppMenu" Property="IsChecked" Value="{Binding Path=ApplicationMenu.IsApplicationMenuOpen, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}" />
            </DataTrigger>
            <Trigger Property="Mode" Value="ShowOnlyTabs">
                <!--<Setter Property="Visibility" Value="Visible" TargetName="hiddenCanvas"/>-->
                <Setter TargetName="PART_ItemsHolder" Property="Margin" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=ShowOnlyTabMargin}}" />
            </Trigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonBar}" TargetType="{x:Type ubcr:RibbonBar}">
        <Setter Property="BorderThickness" Value="0,1" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarBorderBrush}}" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=DefaultRibbonBarTemplate}}" />
    </Style>

    <!--  ================================RibbonTabItem Template And Style==============================================  -->

    <SolidColorBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedTabItemBkBrush}" Color="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteColor}}" />

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonTabItem}, ResourceId=DefaultRibbonTabItemTemplate}" TargetType="{x:Type ubcr:RibbonTabItem}">
        <Grid x:Name="PART_TabItemToot">
            <Border x:Name="PART_RibbonTabItemBorder" Background="{TemplateBinding Background}" />
            <Border x:Name="PART_RibbonTabItemBorder1"
                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=SelectedTabItemBkBrush}}"
                    Visibility="Collapsed" />
            <Border BorderBrush="{TemplateBinding BorderBrush}" 
                    BorderThickness="{TemplateBinding BorderThickness}" />
            <TextBlock x:Name="PART_TabItemText"
                       Margin="{TemplateBinding Padding}"
                       VerticalAlignment="Center"
                       Text="{TemplateBinding Header}" 
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>

        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsContextual" Value="True">
                <Setter TargetName="PART_RibbonTabItemBorder" Property="Opacity" Value=".1" />
                <Setter TargetName="PART_RibbonTabItemBorder1" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter TargetName="PART_TabItemText" Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" />
                <Setter TargetName="PART_RibbonTabItemBorder1" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedTabItemBrush}}" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsContextual" Value="False" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_TabItemText" Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonWindowBorderBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsContextual" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_TabItemText" Property="Foreground" Value="{Binding Path=ContextualTabItemsGroup.Brush, RelativeSource={RelativeSource Mode=Self}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonTabItem}" TargetType="{x:Type ubcr:RibbonTabItem}">
        <Setter Property="BorderThickness" Value="1,1,1,0" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="Padding" Value="15,0" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonTabItem}, ResourceId=DefaultRibbonTabItemTemplate}}" />
        <Style.Triggers>
            <Trigger Property="IsContextual" Value="True">
                <Setter Property="Margin" Value="0" />
                <Setter Property="Background" Value="{Binding Path=ContextualTabItemsGroup.Brush, RelativeSource={RelativeSource Mode=Self}}" />
            </Trigger>

            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedTabItemBkBrush}}" />
                <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarBorderBrush}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================ScrollViewer Template And Style==============================================  -->

    <ControlTemplate x:Key="ScrollerFlatRepeatButton" TargetType="{x:Type RepeatButton}">
        <ubcr:RibbonChrome Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="1"
                           Content="{TemplateBinding Content}"
                           CornerRadius="0"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=WhiteBrush}}"
                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=ScrollerPressedBoderBrush}}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=ScrollerPressedBackgroundBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=ScrollerPressedBoderBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}" />
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalScrollBar_Thumb" TargetType="{x:Type Thumb}">
        <ubcr:RibbonChrome Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="1"
                           CornerRadius="0"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=ScrollerPressedBackgroundBrush}}"
                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=ScrollerBorderBrush}}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=ScrollerPressedBackgroundBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=ScrollerPressedBoderBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsDragging}">
            <Image Margin="0.85,0,0,0"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=HorizontalLines}}"
                   Stretch="None" />
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBar_Thumb" TargetType="{x:Type Thumb}">
        <ubcr:RibbonChrome Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="1"
                           CornerRadius="0"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=ScrollerPressedBackgroundBrush}}"
                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=ScrollerBorderBrush}}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=ScrollerPressedBackgroundBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=ScrollerPressedBoderBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsDragging}">
            <Image HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=VerticalLines}}"
                   Stretch="None" />
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <ControlTemplate x:Key="ScrollBar_PageButton" TargetType="{x:Type RepeatButton}">
        <ubcr:RibbonChrome Background="{TemplateBinding Background}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           CornerRadius="0"
                           InnerBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                ResourceId=TransparentBrush}}"
                           InnerBorderThickness="0"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=PageButtonPressedBackgroundBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=TransparentBrush}}"
                           RenderPressed="{TemplateBinding IsPressed}" />
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                               ResourceId=TransparentBrush}}"
                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                ResourceId=SelectedBorderBrush}}"
                BorderThickness="0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="17" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="17" />
                </Grid.RowDefinitions>
                <RepeatButton x:Name="PART_Uparrow"
                              Width="15"
                              Height="17"
                              HorizontalAlignment="Right"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                             ResourceId=WhiteBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=ScrollerBorderBrush}}"
                              Command="ScrollBar.LineUpCommand"
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}">
                    <Image Width="8"
                           Height="5"
                           Margin="0.8,0,0,0"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Opacity=".8"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                      ResourceId=LineUpArrow}}"
                           Stretch="Fill" />
                </RepeatButton>
                <Track x:Name="PART_Track"
                       Grid.Row="1"
                       IsDirectionReversed="True">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Width="15"
                                      HorizontalAlignment="Right"
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                     ResourceId=ScrollerBackgroundBrush}}"
                                      Command="ScrollBar.PageUpCommand"
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" />
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="PART_Thumb"
                               Width="15"
                               MinHeight="6"
                               HorizontalAlignment="Right"
                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=WhiteBrush}}"
                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=ScrollerBorderBrush}}"
                               Template="{StaticResource ResourceKey=VerticalScrollBar_Thumb}" />
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Width="15"
                                      HorizontalAlignment="Right"
                                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                     ResourceId=ScrollerBackgroundBrush}}"
                                      Command="ScrollBar.PageDownCommand"
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" />
                    </Track.IncreaseRepeatButton>
                </Track>
                <RepeatButton x:Name="PART_Downarrow"
                              Grid.Row="2"
                              Width="15"
                              Height="17"
                              HorizontalAlignment="Right"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                             ResourceId=WhiteBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=ScrollerBorderBrush}}"
                              Command="ScrollBar.LineDownCommand"
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}">
                    <Image Width="8"
                           Height="5"
                           Margin="0.8,0,0,0"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Opacity=".8"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                      ResourceId=LineDownArrow}}"
                           Stretch="Fill" />
                </RepeatButton>
            </Grid>
        </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                               ResourceId=TransparentBrush}}"
                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                ResourceId=SelectedBorderBrush}}"
                BorderThickness="0">
            <Grid Width="{TemplateBinding ActualWidth}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="17" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="17" />
                </Grid.ColumnDefinitions>
                <RepeatButton x:Name="PART_Leftarrow"
                              Grid.Column="0"
                              Width="17"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                             ResourceId=WhiteBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=ScrollerBorderBrush}}"
                              Command="ScrollBar.LineLeftCommand"
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}">
                    <Image Width="5"
                           Height="8"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Opacity="0.8"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                      ResourceId=LineLeftArrow}}"
                           Stretch="Fill" />
                </RepeatButton>
                <Track Name="PART_Track"
                       Grid.Column="1"
                       IsDirectionReversed="False">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                     ResourceId=ScrollerBackgroundBrush}}"
                                      Command="ScrollBar.PageLeftCommand"
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" />
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb x:Name="PART_Thumb"
                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=WhiteBrush}}"
                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=ScrollerBorderBrush}}"
                               Template="{StaticResource ResourceKey=HorizontalScrollBar_Thumb}" />
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                     ResourceId=ScrollerBackgroundBrush}}"
                                      Command="ScrollBar.PageRightCommand"
                                      Template="{StaticResource ResourceKey=ScrollBar_PageButton}" />
                    </Track.IncreaseRepeatButton>
                </Track>
                <RepeatButton x:Name="PART_Rightarrow"
                              Grid.Column="2"
                              Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                             ResourceId=WhiteBrush}}"
                              BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=ScrollerBorderBrush}}"
                              Command="ScrollBar.LineRightCommand"
                              Template="{StaticResource ResourceKey=ScrollerFlatRepeatButton}">
                    <Image Width="5"
                           Height="8"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Opacity="0.8"
                           Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                      ResourceId=LineRightArrow}}"
                           Stretch="Fill" />
                </RepeatButton>
            </Grid>
        </Border>
    </ControlTemplate>

    <Style x:Key="DefaultScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Height" Value="16" />
                <Setter Property="Width" Value="Auto" />
                <Setter Property="MinWidth" Value="42" />
                <Setter Property="Template" Value="{StaticResource ResourceKey=HorizontalScrollBarTemplate}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Width" Value="16" />
                <Setter Property="MinHeight" Value="42" />
                <Setter Property="Template" Value="{StaticResource ResourceKey=VerticalScrollBarTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <ControlTemplate x:Key="DeafultScrollViewerTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid x:Name="PART_Root">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ScrollContentPresenter CanContentScroll="{TemplateBinding CanContentScroll}" Content="{TemplateBinding Content}" />
            <ScrollBar x:Name="PART_VerticalScrollBar"
                       Grid.Row="0"
                       Grid.Column="1"
                       Maximum="{TemplateBinding ScrollableHeight}"
                       Minimum="0"
                       Orientation="Vertical"
                       Style="{StaticResource ResourceKey=DefaultScrollBarStyle}"
                       ViewportSize="{TemplateBinding ViewportHeight}"
                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                       Value="{TemplateBinding VerticalOffset}" />
            <ScrollBar x:Name="PART_HorizontalScrollBar"
                       Grid.Row="1"
                       Grid.Column="0"
                       Maximum="{TemplateBinding ScrollableWidth}"
                       Minimum="0"
                       Orientation="Horizontal"
                       Style="{StaticResource ResourceKey=DefaultScrollBarStyle}"
                       ViewportSize="{TemplateBinding ViewportWidth}"
                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                       Value="{TemplateBinding HorizontalOffset}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger SourceName="PART_VerticalScrollBar" Property="Visibility" Value="Collapsed">
                <Setter Property="MinWidth" Value="42.0" />
            </Trigger>
            <Trigger SourceName="PART_HorizontalScrollBar" Property="Visibility" Value="Collapsed">
                <Setter Property="MinHeight" Value="42.0" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="ScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
        <Setter Property="IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="Template" Value="{StaticResource ResourceKey=DeafultScrollViewerTemplate}" />
    </Style>

    <!--  ================================ApplicationMenu Template And Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenu}, ResourceId=CircularButtonTemplate}" TargetType="{x:Type Button}">
        <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
            <Ellipse x:Name="ellipse"
                     Width="{TemplateBinding Width}"
                     Height="{TemplateBinding Height}"
                     Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=TransparentBrush}}"
                     Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                ResourceId=LeftArrowImage_DefaultStateBrush}}"
                     StrokeThickness="2" />
            <Image x:Name="image"
                   Margin="8"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=LeftArrowImage_DefaultState}}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="image" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LeftArrowImage_MouseOverState}}" />
                <Setter TargetName="ellipse" Property="Stroke" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LeftArrowImage_MouseOverStateBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Visibility x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=AppMenuSwirlVisibility}">Collapsed</Visibility>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenu}, ResourceId=DefaultApplicationMenuTemplate}" TargetType="{x:Type ubcr:ApplicationMenu}">
        <Themes:SystemDropShadowChrome x:Name="shadowChrome" Color="#41000000">
            <Grid x:Name="PART_AppMenuRootPanel"
                  Margin="0,0,5,5"
                  Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                 ResourceId=TransparentBrush}}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid x:Name="Panegrid"
                      Width="{TemplateBinding ItemsPanelWidth}"
                      Margin="0"
                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                     ResourceId=AppMenuItemsPanelBrush}}">
                    <Grid.RowDefinitions>
                        <RowDefinition x:Name="buttonRow" Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Button x:Name="circularButton"
                            Width="33"
                            Height="33"
                            Margin="30, 0, 0, 0"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Command="{Binding Path=OpenCloseAppMenuCommand,
                                              RelativeSource={RelativeSource Mode=FindAncestor,
                                                                             AncestorType={x:Type ubcr:RibbonWindow}}}"
                            CommandParameter="False"
                            Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenu},
                                                                                         ResourceId=CircularButtonTemplate}}"
                            Visibility="Collapsed" />
                    <ItemsPresenter Grid.Row="1" />

                </Grid>
                <Grid Grid.Column="1"
                      Margin="0"
                      Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                     ResourceId=AppMenuSelectedContentBackgroundBrush}}">
                    <Border Width="300"
                            Height="200"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Bottom"
                            Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=AppMenuSwirlBrush}}"
                            Opacity="0.6"
                            RenderTransformOrigin="0.5,0.5"
                            SnapsToDevicePixels="False"
                            Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=AppMenuSwirlVisibility}}">
                        <Border.RenderTransform>
                            <RotateTransform Angle="-180" />
                        </Border.RenderTransform>
                    </Border>
                    <Border x:Name="PART_AppMenuContentBorder" />
                </Grid>
            </Grid>
        </Themes:SystemDropShadowChrome>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=Theme, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonWindow}}, NotifyOnSourceUpdated=True}" Value="Default" />
                    <Condition Binding="{Binding Path=MenuStyle, RelativeSource={RelativeSource Mode=Self}, NotifyOnSourceUpdated=True}" Value="Default" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter TargetName="Panegrid" Property="Margin" Value="0,-29,0,0" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
            <Trigger Property="MenuStyle" Value="Default">
                <Setter TargetName="PART_AppMenuRootPanel" Property="Margin" Value="0" />
                <Setter TargetName="shadowChrome" Property="Color" Value="Transparent" />

                <Setter TargetName="buttonRow" Property="Height" Value="65" />
                <Setter TargetName="circularButton" Property="Visibility" Value="Visible" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:ApplicationMenu}" TargetType="{x:Type ubcr:ApplicationMenu}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanelWidth" Value="200" />
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=AppMenuItemsPanelBrush}}" />
        <Setter Property="Padding" Value="15,3" />
        <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenu}, ResourceId=DefaultApplicationMenuTemplate}}" />
    </Style>

    <!--  ================================ApplicationMenuItem Template And Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=SelectableApplicationMenuItemTemplate}" TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <ubcr:RibbonChrome VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=TransparentBrush}}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           Content="{TemplateBinding TitleContent}"
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=WhiteBrush}}"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=MouseOverMenuBackgroundBrush}}"
                           Padding="{TemplateBinding Padding}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=SelectedMenuBackgroundBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsSelected}" />

    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=NoneSelectableApplicationMenuItemTemplate}" TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <ubcr:RibbonChrome VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=TransparentBrush}}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           Content="{TemplateBinding TitleContent}"
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=WhiteBrush}}"
                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=MouseOverMenuBackgroundBrush}}"
                           Padding="{TemplateBinding Padding}"
                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=SelectedMenuBackgroundBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}" />

    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:ApplicationMenuItem}" TargetType="{x:Type ubcr:ApplicationMenuItem}">
        <Setter Property="MinHeight" Value="45" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="30,0,0,0" />
        <Style.Triggers>
            <Trigger Property="IsSelectable" Value="True">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=SelectableApplicationMenuItemTemplate}}" />
            </Trigger>
            <Trigger Property="IsSelectable" Value="False">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:ApplicationMenuItem}, ResourceId=NoneSelectableApplicationMenuItemTemplate}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================DropDownMenuItem Template and Style==============================================  -->
    <ControlTemplate x:Key="{x:Static ubcr:DropDownMenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type ubcr:DropDownMenuItem}">
        <Border x:Name="Border" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="28" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="10" />
                </Grid.ColumnDefinitions>
                <Image Width="17"
                       Height="17"
                       Margin="3,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{TemplateBinding Image}" />
                <Popup x:Name="Popup"
                       AllowsTransparency="True"
                       Focusable="False"
                       HorizontalOffset="-3.8"
                       IsOpen="{TemplateBinding IsSubmenuOpen}"
                       Placement="Right">
                    <Border x:Name="SubmenuBorder"
                            Width="{TemplateBinding MaxDropDownWidth}"
                            Margin="7"
                            Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownBackgroundBrush}}"
                            BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                            ResourceId=DropDownBorderBrush}}"
                            BorderThickness="1"
                            SnapsToDevicePixels="True">
                        <Border.RenderTransform>
                            <TranslateTransform />
                        </Border.RenderTransform>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Border Grid.RowSpan="2"
                                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                   ResourceId=DropDownBackgroundBrush}}"
                                    Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownShadowEffect}}" />
                            <ScrollViewer CanContentScroll="True"
                                          Style="{StaticResource ScrollViewerStyle}"
                                          VerticalScrollBarVisibility="Auto">
                                <StackPanel x:Name="PART_DropDownMenuItemsHost"
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" />
                            </ScrollViewer>
                        </Grid>

                    </Border>
                </Popup>
                <ContentPresenter x:Name="headerPresenter"
                                  Grid.Column="1"
                                  Margin="6,3,6,3"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True" 
                                  TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                <Image Grid.Row="1"
                       Grid.Column="2"
                       Width="3"
                       Height="6"
                       Margin="0,0,3,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=RightArrow}}"
                       Stretch="Fill" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="headerPresenter" Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{x:Static ubcr:DropDownMenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type ubcr:DropDownMenuItem}">
        <Border x:Name="Border" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="28" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Image Width="17"
                       Height="17"
                       Margin="3,0"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Center"
                       Source="{TemplateBinding Image}" />
                <ContentPresenter x:Name="HeaderHost"
                                  Grid.Column="1"
                                  Margin="6,3,6,3"
                                  VerticalAlignment="Center"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True" 
                                  TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="HeaderHost" Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{x:Static ubcr:DropDownMenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type ubcr:DropDownMenuItem}">
        <Border x:Name="Border"
                Grid.Row="1"
                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                               ResourceId=DropDownBackgroundBrush}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="28" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
                    <ColumnDefinition Width="10" />
                </Grid.ColumnDefinitions>
                <Image Width="17"
                       Height="17"
                       Margin="3,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{TemplateBinding Image}" />
                <Popup x:Name="Popup"
                       AllowsTransparency="True"
                       Focusable="False"
                       HorizontalOffset="-3.8"
                       IsOpen="{TemplateBinding IsSubmenuOpen}"
                       Placement="Right">
                    <Border x:Name="SubmenuBorder"
                            Width="{TemplateBinding MaxDropDownWidth}"
                            Margin="7"
                            Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownBackgroundBrush}}"
                            BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                            ResourceId=DropDownBorderBrush}}"
                            BorderThickness="1"
                            SnapsToDevicePixels="True">
                        <Border.RenderTransform>
                            <TranslateTransform />
                        </Border.RenderTransform>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Border Grid.RowSpan="2"
                                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                   ResourceId=DropDownBackgroundBrush}}"
                                    Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownShadowEffect}}" />
                            <ScrollViewer CanContentScroll="True"
                                          Style="{StaticResource ScrollViewerStyle}"
                                          VerticalScrollBarVisibility="Auto">
                                <StackPanel x:Name="PART_DropDownMenuItemsHost"
                                            IsItemsHost="True"
                                            KeyboardNavigation.DirectionalNavigation="Cycle" />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </Popup>
                <ContentPresenter x:Name="HeaderHost"
                                  Grid.Column="1"
                                  Margin="6,3,6,3"
                                  VerticalAlignment="Center"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True" 
                                  TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                <TextBlock x:Name="InputGestureText"
                           Grid.Column="2"
                           Margin="5,2,2,2"
                           DockPanel.Dock="Right"
                           Text="{TemplateBinding InputGestureText}" 
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                <Image Grid.Column="3"
                       Width="3"
                       Height="6"
                       Margin="0,0,3,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=RightArrow}}"
                       Stretch="Fill" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter TargetName="HeaderHost" Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{x:Static ubcr:DropDownMenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type ubcr:DropDownMenuItem}">
        <Border x:Name="Border" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="28" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Image Width="17"
                       Height="17"
                       Margin="3,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{TemplateBinding Image}" />
                <ContentPresenter x:Name="HeaderHost"
                                  Grid.Column="1"
                                  Margin="6,3,6,3"
                                  VerticalAlignment="Center"
                                  ContentSource="Header"
                                  RecognizesAccessKey="True" 
                                  TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                <TextBlock x:Name="InputGestureText"
                           Grid.Column="2"
                           Margin="5,2,0,2"
                           DockPanel.Dock="Right"
                           Text="{TemplateBinding InputGestureText}" 
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="ButtonBase.Command" Value="{x:Null}" />
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="False" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                </MultiTrigger.Setters>
            </MultiTrigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter TargetName="HeaderHost" Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:DropDownMenuItem}" TargetType="{x:Type ubcr:DropDownMenuItem}">
        <Setter Property="MinHeight" Value="25" />
        
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static ubcr:DropDownMenuItem.TopLevelHeaderTemplateKey}}" />
                <Setter Property="Grid.IsSharedSizeScope" Value="True" />
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource {x:Static ubcr:DropDownMenuItem.TopLevelItemTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static ubcr:DropDownMenuItem.SubmenuHeaderTemplateKey}}" />
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource {x:Static ubcr:DropDownMenuItem.SubmenuItemTemplateKey}}" />
            </Trigger>
            <Trigger Property="Header" Value="{x:Null}">
                <Setter Property="MinHeight" Value="0" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================RibbonGalleryItem Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGalleryItem}, ResourceId=RibbonGalleryItemTemplate}" TargetType="{x:Type ubcr:RibbonGalleryItem}">
        <ubcr:RibbonChrome x:Name="chrome"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           CornerRadius="0"
                           InnerBorderCornerRadius="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}">
            <ContentPresenter Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              RecognizesAccessKey="True" />
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonGalleryItem}" TargetType="{x:Type ubcr:RibbonGalleryItem}">
        <Setter Property="Padding" Value="3" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="Template" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGalleryItem}, ResourceId=RibbonGalleryItemTemplate}}" />
    </Style>

    <!--  ================================RibbonGallery Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=RepeatButtonTemplate}" TargetType="{x:Type RepeatButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           BorderThickness="{TemplateBinding BorderThickness}"
                           Content="{TemplateBinding Content}"
                           CornerRadius="0"
                           InnerBorderCornerRadius="0"
                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=MouseOverBackgroundBrush}}"
                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=PressedBackgroundBrush}}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsPressed}" />
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=RibbonGalleryTemplate}" TargetType="{x:Type ubcr:RibbonGallery}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Border x:Name="headerBorder"
                    Height="26"
                    Background="{TemplateBinding HeaderBackground}">
                <ContentPresenter Margin="6,3,0,3"
                                  VerticalAlignment="Center"
                                  ContentSource="Header"
                                  ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                  ContentTemplate="{TemplateBinding HeaderTemplate}"
                                  ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                  TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Border>
            <ScrollViewer Grid.Row="1"
                          CanContentScroll="True"
                          HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
                          Style="{StaticResource ScrollViewerStyle}"
                          VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}">
                <StackPanel>
                    <ItemsPresenter />
                </StackPanel>
            </ScrollViewer>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="Header" Value="{x:Null}">
                <Setter TargetName="headerBorder" Property="Height" Value="0" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=InGroupGalleryTemplate}" TargetType="{x:Type ubcr:RibbonGallery}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="21" />
                <RowDefinition Height="21" />
                <RowDefinition Height="21" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
            </Grid.ColumnDefinitions>
            <Border Grid.RowSpan="3"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=GalleryBorderBrush}}"
                    BorderThickness="1,1,0,1">

                <ubcr:RibbonGalleryPanel CurrentIndex="{TemplateBinding CurrentIndex}"
                                         IsItemsHost="True"
                                         VisibleItemsCount="{TemplateBinding VisibleItemsCount}" />

            </Border>
            <Popup x:Name="PART_RibbonGalleryPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="Top"
                   PlacementTarget="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-63">
                <Border x:Name="SubmenuBorder"
                        Width="{TemplateBinding MaxDropDownWidth}"
                        MinWidth="{TemplateBinding ActualWidth}"
                        Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1"
                        SnapsToDevicePixels="True">
                    <Grid x:Name="PART_RGResizablePanel" VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />

                        <StackPanel x:Name="PART_RibbonGalleryItemsPanel" />

                        <!--<ContentPresenter Content="{TemplateBinding DropDownGalleries}"/>-->
                        <Thumb x:Name="PART_RibbonGalleryThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=CanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
            <RepeatButton x:Name="PART_UpButton"
                          Grid.Row="0"
                          Grid.Column="1"
                          Width="15"
                          Height="21"
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=GalleryBorderBrush}}"
                          BorderThickness="1,1,1,0"
                          Command="{Binding Path=LineUpCommand,
                                            RelativeSource={RelativeSource Mode=TemplatedParent}}"
                          FocusVisualStyle="{x:Null}"
                          Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery},
                                                                                      ResourceId=RepeatButtonTemplate}}">
                <Image x:Name="img1"
                       Width="8"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=UpArrowImage}}"
                       Stretch="None" />
            </RepeatButton>
            <RepeatButton x:Name="PART_DownButton"
                          Grid.Row="1"
                          Grid.Column="1"
                          Width="15"
                          Height="21"
                          BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=GalleryBorderBrush}}"
                          BorderThickness="1"
                          Command="{Binding Path=LineDownCommand,
                                            RelativeSource={RelativeSource Mode=TemplatedParent}}"
                          Focusable="False"
                          IsTabStop="False"
                          Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery},
                                                                                      ResourceId=RepeatButtonTemplate}}">
                <Image x:Name="img2"
                       Width="8"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=DownArrowImage}}"
                       Stretch="None" />
            </RepeatButton>
            <Button x:Name="PART_ThirdButton"
                    Grid.Row="2"
                    Grid.Column="1"
                    Width="15"
                    Height="21"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=GalleryBorderBrush}}"
                    BorderThickness="1,0,1,1"
                    Command="{Binding Path=OpenDropDownCommand,
                                      RelativeSource={RelativeSource Mode=FindAncestor,
                                                                     AncestorType={x:Type ubcr:RibbonGallery}}}"
                    Focusable="False"
                    IsTabStop="False">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                                           VerticalContentAlignment="Center"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           BorderThickness="{TemplateBinding BorderThickness}"
                                           CornerRadius="0"
                                           InnerBorderCornerRadius="0"
                                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                    ResourceId=MouseOverBackgroundBrush}}"
                                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                  ResourceId=PressedBackgroundBrush}}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsPressed}">
                            <Image x:Name="image"
                                   Width="7"
                                   Height="7"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=skin:SkinManager,
                                                                                              ResourceId=QAToolBarMenuArrow}}"
                                   Stretch="Fill" />
                        </ubcr:RibbonChrome>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="image" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=skin:SkinManager, ResourceId=DisabledQAToolBarMenuArrow}}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>

            </Button>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter Property="Width" Value="95" />
                <Setter Property="IsEnabled" Value="False" />
            </Trigger>
            <Trigger SourceName="PART_UpButton" Property="IsEnabled" Value="False">
                <Setter TargetName="img1" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=skin:SkinManager, ResourceId=DisabledUpArrowImage}}" />
                <Setter TargetName="PART_UpButton" Property="BorderThickness" Value="0,1,1,0" />
            </Trigger>
            <Trigger SourceName="PART_DownButton" Property="IsEnabled" Value="False">
                <Setter TargetName="img2" Property="Source" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly=skin:SkinManager, ResourceId=DisabledDownArrowImage}}" />
                <Setter TargetName="PART_DownButton" Property="BorderThickness" Value="0,1,1,1" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery},
                                        ResourceId=DefaultItemContainerStyle}"
           x:Shared="False"
           TargetType="{x:Type ubcr:RibbonGalleryItem}">
        <Setter Property="Width" Value="70.0" />
        <Setter Property="Height" Value="61.0" />
        <Setter Property="FocusVisualStyle">
            <Setter.Value>
                <Style TargetType="{x:Type Control}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Control}">
                                <Border BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" BorderThickness="4" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ubcr:RibbonGalleryItem}">
                    <ubcr:RibbonChrome x:Name="chrome"
                                       Width="{TemplateBinding Width}"
                                       Height="{TemplateBinding Height}"
                                       BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                       ResourceId=TransparentBrush}}"
                                       BorderThickness="3"
                                       CornerRadius="0"
                                       MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                    ResourceId=TransparentBrush}}"
                                       MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                ResourceId=MouseOverBackgroundBrush}}"
                                       PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                  ResourceId=TransparentBrush}}"
                                       PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                              ResourceId=PressedBackgroundBrush}}"
                                       RenderMouseOver="{TemplateBinding IsMouseOver}"
                                       RenderPressed="{TemplateBinding IsPressed}">
                        <ContentPresenter Margin="{TemplateBinding Padding}" ContentSource="Content" />
                    </ubcr:RibbonChrome>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter TargetName="chrome" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedGalleryItemBrush}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type ubcr:RibbonGallery}" TargetType="{x:Type ubcr:RibbonGallery}">
        <Setter Property="HeaderBackground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GalleryHeaderBrush}}" />
        <Style.Triggers>
            <Trigger Property="IsInGroup" Value="False">
                <Setter Property="Template" Value="{StaticResource {ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=RibbonGalleryTemplate}}" />
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <WrapPanel />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsInGroup" Value="True">
                <Setter Property="Template" Value="{StaticResource {ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=InGroupGalleryTemplate}}" />
                <Setter Property="ItemContainerStyle" Value="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallery}, ResourceId=DefaultItemContainerStyle}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================RibbonDropDownButtonTemplate (small size)==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonDropDownButton}, ResourceId=SmallRibbonDropDownButtonTemplate}" TargetType="{x:Type ubcr:RibbonDropDownButton}">
        <Grid>
            <ToggleButton Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          ClickMode="{TemplateBinding ClickMode}"
                          Command="{TemplateBinding Command}"
                          CommandParameter="{TemplateBinding CommandParameter}"
                          CommandTarget="{TemplateBinding CommandTarget}"
                          Content="{TemplateBinding Title}"
                          FocusVisualStyle="{x:Null}"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                                           Background="{TemplateBinding Background}"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <Grid Width="{TemplateBinding Width}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Image x:Name="image"
                                       Grid.Column="0"
                                       Width="16"
                                       Height="16"
                                       Margin="2, 0, 3, 0"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Source="{Binding Path=Image,
                                                        RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                       AncestorType={x:Type ubcr:RibbonDropDownButton}}}"
                                       Stretch="Fill" />
                                <TextBlock x:Name="content"
                                           Grid.Column="1"
                                           Margin="3, 0, 5, 0"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           FontSize="11"
                                           Text="{TemplateBinding Content}"
                                           TextAlignment="Center"
                                           TextTrimming="CharacterEllipsis"
                                           TextWrapping="NoWrap" 
                                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                                <Image Grid.Column="2"
                                       Width="6"
                                       Height="3"
                                       Margin="0, 0, 5, 0"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       RenderOptions.BitmapScalingMode="HighQuality"
                                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=ExpandImage}}"
                                       Stretch="Fill" />
                            </Grid>
                        </ubcr:RibbonChrome>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="{Binding Path=DropDownPlacement,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       Mode=OneWay,
                                       NotifyOnSourceUpdated=True}"
                   PlacementTarget="{Binding Path=PlacementTarget,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Mode=OneWay,
                                             NotifyOnSourceUpdated=True}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          MaxHeight="{TemplateBinding MaxDropDownHeight}"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <StackPanel x:Name="PART_DropDownButtonItemsHost"
                                    Margin="1"
                                    FocusVisualStyle="{x:Null}"
                                    Focusable="True"
                                    IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonDropDownButton}, ResourceId=LargeRibbonDropDownButtonTemplate}" TargetType="{x:Type ubcr:RibbonDropDownButton}">
        <Grid>
            <ToggleButton Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          ClickMode="{TemplateBinding ClickMode}"
                          Command="{TemplateBinding Command}"
                          CommandParameter="{TemplateBinding CommandParameter}"
                          CommandTarget="{TemplateBinding CommandTarget}"
                          Content="{TemplateBinding Title}"
                          FocusVisualStyle="{x:Null}"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                                           Background="{TemplateBinding Background}"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           Focusable="False"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <Grid Margin="4,0,4,0">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Image x:Name="image"
                                       Width="32"
                                       Height="32"
                                       Margin="0,0.5,0,0"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Focusable="False"
                                       Source="{Binding Path=Image,
                                                        RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                       AncestorType={x:Type ubcr:RibbonDropDownButton}},
                                                        Mode=OneWay}" />
                                <ubcr:TwoLineText x:Name="text"
                                                  Grid.Row="1"
                                                  Margin="3, 0, 5, 0"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Top"
                                                  Focusable="False"
                                                  FontSize="11"
                                                  ImageVisibility="Visible"
                                                  Text="{TemplateBinding Content}" />
                            </Grid>
                        </ubcr:RibbonChrome>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="{Binding Path=DropDownPlacement,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       Mode=OneWay,
                                       NotifyOnSourceUpdated=True}"
                   PlacementTarget="{Binding Path=PlacementTarget,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Mode=OneWay,
                                             NotifyOnSourceUpdated=True}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          Height="{TemplateBinding DropDownHeight}"
                          MinHeight="32.0"
                          MaxWidth="{TemplateBinding MaxDropDownWidth}"
                          MaxHeight="{TemplateBinding MaxDropDownHeight}"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <StackPanel x:Name="PART_DropDownButtonItemsHost"
                                    Margin="1"
                                    FocusVisualStyle="{x:Null}"
                                    Focusable="True"
                                    IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonDropDownButton}" TargetType="{x:Type ubcr:RibbonDropDownButton}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="PlacementTarget" Value="{Binding RelativeSource={RelativeSource Mode=Self}}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Style.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Height" Value="23" />
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonDropDownButton}, ResourceId=SmallRibbonDropDownButtonTemplate}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
            </Trigger>
            <Trigger Property="Size" Value="Large">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonDropDownButton}, ResourceId=LargeRibbonDropDownButtonTemplate}}" />
                <Setter Property="Height" Value="69" />
                <Setter Property="Width" Value="Auto" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================RibbonGallerySet template and style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox}, ResourceId=FilterComboBoxTemplate}" TargetType="{x:Type ubcr:RibbonComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup"
                   Grid.ColumnSpan="2"
                   Margin="1"
                   AllowsTransparency="True"
                   IsOpen="{Binding IsDropDownOpen,
                                    Mode=TwoWay,
                                    RelativeSource={RelativeSource TemplatedParent}}"
                   Placement="Bottom"
                   PopupAnimation="None"
                   VerticalOffset="-4.2">
                <Border x:Name="DropDownBorder"
                        MinWidth="{Binding ActualWidth,
                                           ElementName=templateRoot}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}"
                        Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          VerticalAlignment="Top">
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <ItemsPresenter x:Name="ItemsPresenter"
                                        KeyboardNavigation.DirectionalNavigation="Contained"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                </Border>
            </Popup>
            <ToggleButton x:Name="toggleButton"
                          Grid.ColumnSpan="2"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}"
                          IsChecked="{Binding IsDropDownOpen,
                                              Mode=TwoWay,
                                              RelativeSource={RelativeSource TemplatedParent}}">
                <ToggleButton.Style>
                    <Style TargetType="{x:Type ToggleButton}">
                        <Setter Property="IsTabStop" Value="False" />
                        <Setter Property="Focusable" Value="False" />
                        <Setter Property="ClickMode" Value="Press" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                    <Border Grid.ColumnSpan="2"
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}">
                                        <Border x:Name="splitBorder"
                                                Width="15"
                                                Margin="0,0,8,0"
                                                HorizontalAlignment="Right"
                                                SnapsToDevicePixels="True">
                                            <Path x:Name="Arrow"
                                                  Margin="0, -3, 0, 0"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center"
                                                  Data="M0,4 L 6,4 L 3,8 L 0,4"
                                                  Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=BlackBrush}}" />
                                        </Border>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="Arrow" Property="Fill" Value="#FFBFBFBF" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ToggleButton.Style>
            </ToggleButton>
            <TextBlock Margin="{TemplateBinding Padding}"
                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                       IsHitTestVisible="False"
                       SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                       Text="{Binding Path=SelectionBoxItem.Header,
                                      RelativeSource={RelativeSource Mode=TemplatedParent},
                                      NotifyOnSourceUpdated=True}" 
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter TargetName="PART_RibbonDropDownButtonResize" Property="Height" Value="95" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallerySet}, ResourceId=GallerySetTemplate}" TargetType="{x:Type ubcr:RibbonGallerySet}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <ubcr:RibbonComboBox x:Name="PART_FilterComboBox"
                                 Margin="0,1"
                                 HorizontalAlignment="Right"
                                 HorizontalContentAlignment="Right"
                                 VerticalContentAlignment="Center"
                                 BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                 ResourceId=TransparentBrush}}"
                                 ItemsSource="{Binding Path=FilterItemsCollection,
                                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                                       NotifyOnSourceUpdated=True}"
                                 Padding="0, 0, 15, 0"
                                 Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox},
                                                                                              ResourceId=FilterComboBoxTemplate}}"
                                 Visibility="{Binding Path=IsFilterEnabled,
                                                      RelativeSource={RelativeSource Mode=TemplatedParent},
                                                      Mode=OneWay,
                                                      Converter={StaticResource ResourceKey=BooleanConverter}}">
                <ubcr:RibbonComboBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="28" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Image Width="7"
                                   Height="8"
                                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=TickImage}}"
                                   Stretch="Fill"
                                   Visibility="{Binding Path=IsSelected,
                                                        NotifyOnSourceUpdated=True,
                                                        Mode=OneWay,
                                                        Converter={StaticResource ResourceKey=BooleanConverter}}" />
                            <TextBlock Grid.Column="1"
                                       Margin="6,3"
                                       VerticalAlignment="Center"
                                       Text="{Binding Path=Header}" 
                                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                        </Grid>
                    </DataTemplate>
                </ubcr:RibbonComboBox.ItemTemplate>
                <ubcr:RibbonComboBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ubcr:RibbonComboBoxItem}">
                        <Setter Property="SnapsToDevicePixels" Value="True" />
                        <Setter Property="Padding" Value="4,1" />
                        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
                        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
                        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="FocusVisualStyle">
                            <Setter.Value>
                                <Style>
                                    <Setter Property="Control.Template">
                                        <Setter.Value>
                                            <ControlTemplate>
                                                <Rectangle Margin="2"
                                                           SnapsToDevicePixels="True"
                                                           Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                      ResourceId=SelectedMenuBackgroundBrush}}"
                                                           StrokeDashArray="1 2"
                                                           StrokeThickness="1" />
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ubcr:RibbonComboBoxItem}">
                                    <Border x:Name="Bd"
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Padding="{TemplateBinding Padding}"
                                            SnapsToDevicePixels="True">
                                        <ContentPresenter />
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ubcr:RibbonComboBox.ItemContainerStyle>
            </ubcr:RibbonComboBox>
            <ScrollViewer Grid.Row="1"
                          CanContentScroll="True"
                          HorizontalScrollBarVisibility="Auto"
                          Style="{StaticResource ScrollViewerStyle}"
                          VerticalScrollBarVisibility="Auto">
                <ItemsPresenter />
            </ScrollViewer>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonGallerySet}" TargetType="{x:Type ubcr:RibbonGallerySet}">
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGallerySet}, ResourceId=GallerySetTemplate}}" />
    </Style>

    <!--  ================================RibbonGroup template and style==============================================  -->

    <Visibility x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonGroupSeparatorVisibility}">Visible</Visibility>

    <Visibility x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonGroupBorderVisibility}">Collapsed</Visibility>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGroup}, ResourceId=DefaultRibbonGroupTemplate}" TargetType="{x:Type ubcr:RibbonGroup}">
        <Grid x:Name="PART_Root">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ubcr:RibbonGroupPanel x:Name="PART_RibbonGroupPanel"
                                   Margin="2,5,5,0"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Top"
                                   IsItemsHost="True" />
            <Border Grid.RowSpan="2"
                    Margin="0,4"
                    HorizontalAlignment="Right"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=LightGrayBrush}}"
                    BorderThickness="0.5"
                    Opacity="0.7"
                    Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=RibbonGroupSeparatorVisibility}}" />
            <Border Grid.RowSpan="2"
                    Margin="0, 1, 1,1"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=RibbonGroupBorderBrush}}"
                    BorderThickness="1"
                    CornerRadius="4"
                    Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=RibbonGroupBorderVisibility}}" />
            <Border Grid.Row="1"
                    Margin="1,1.5,1.5,1.5"
                    Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=RibbonGroupFooterBrush}}"
                    CornerRadius="0,0,4,4"
                    Focusable="False"
                    Visibility="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                   ResourceId=RibbonGroupBorderVisibility}}" />
            <DockPanel Grid.Row="1"
                       Width="{Binding Path=ActualWidth,
                                       ElementName=PART_RibbonGroupPanel,
                                       Mode=OneWay}"
                       Focusable="False"
                       LastChildFill="True">
                <Button x:Name="PART_Launcher"
                        Width="16"
                        Height="16"
                        VerticalAlignment="Bottom"
                        DockPanel.Dock="Right"
                        Visibility="{Binding Path=HasLauncher,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Converter={StaticResource BooleanConverter}}">
                    <Button.Template>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <ubcr:RibbonChrome Margin="0,0,2,0.7"
                                               HorizontalContentAlignment="Center"
                                               VerticalContentAlignment="Bottom"
                                               Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                              ResourceId=TransparentBrush}}"
                                               BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                               ResourceId=TransparentBrush}}"
                                               Padding="3,3,3,2"
                                               RenderMouseOver="{TemplateBinding IsMouseOver}"
                                               RenderPressed="{TemplateBinding IsPressed}">
                                <Image RenderOptions.BitmapScalingMode="Linear"
                                       RenderOptions.EdgeMode="Aliased"
                                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=LauncherButtonImage}}" />
                            </ubcr:RibbonChrome>
                        </ControlTemplate>
                    </Button.Template>
                </Button>
                <TextBlock Margin="2, 0, 2, 0.7"
                           VerticalAlignment="Bottom"
                           DockPanel.Dock="Left"
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                          ResourceId=DefaultForegroundBrush}}"
                           Text="{TemplateBinding Header}"
                           TextAlignment="Center"
                           TextTrimming="CharacterEllipsis" />
            </DockPanel>
        </Grid>

    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGroup}, ResourceId=MinimizedRibbonGroupTemplate}" TargetType="{x:Type ubcr:RibbonGroup}">
        <Grid>
            <ToggleButton x:Name="PART_Toogle"
                          ClickMode="Press"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=SplitterBorderBrush}}"
                                           BorderThickness="0, 0, 1, 0"
                                           InnerBorderBrush="#C0FFFFFF"
                                           InnerBorderThickness="1.2, 0, 1.2, 0"
                                           MouseOverBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                        ResourceId=MinimizedGroupMouseOverBrush}}"
                                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                    ResourceId=TransparentBrush}}"
                                           Padding="10, 3, 10, 0"
                                           PressedBackgroundBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                      ResourceId=DefaultTransitionBrush}}"
                                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                  ResourceId=SplitterBorderBrush}}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <Grid MaxWidth="86">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Border Width="30"
                                        Height="30"
                                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                       ResourceId=DropDownBackgroundBrush}}"
                                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                        ResourceId=SelectedBorderBrush}}"
                                        BorderThickness="1">
                                    <Image Width="17"
                                           Height="17"
                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                           Source="{Binding Path=Image,
                                                            Mode=OneWay,
                                                            RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                           AncestorType={x:Type ubcr:RibbonGroup}}}"
                                           Stretch="Fill" />
                                </Border>
                                <TextBlock Grid.Row="1"
                                           Margin="0,2,0,0"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Top"
                                           Text="{Binding Path=Header,
                                                          RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                         AncestorType={x:Type ubcr:RibbonGroup}}}"
                                           TextWrapping="NoWrap" 
                                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                                <Image Grid.Row="2"
                                       Width="6"
                                       Height="3"
                                       Margin="0,5,0,0"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Top"
                                       RenderOptions.BitmapScalingMode="Linear"
                                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                  ResourceId=ExpandImage}}"
                                       Stretch="Fill" />
                            </Grid>
                        </ubcr:RibbonChrome>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="Bottom"
                   PlacementTarget="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <ScrollViewer ubcr:ScrollViewerHelper.Attach="True"
                                      CanContentScroll="True"
                                      Template="{StaticResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonScrollViewer},
                                                                                                  ResourceId=SidedScrollViewerTemplate}}">
                            <ubcr:RibbonStackPanel Margin="2,2,2,0"
                                                   Focusable="False"
                                                   Orientation="Horizontal">
                                <ubcr:RibbonGroupPanel x:Name="PART_RibbonGroupPanel" IsItemsHost="True" />
                            </ubcr:RibbonStackPanel>
                        </ScrollViewer>
                        <DockPanel Grid.Row="1" LastChildFill="True">
                            <Button x:Name="PART_Launcher"
                                    Width="16"
                                    Height="16"
                                    VerticalAlignment="Bottom"
                                    DockPanel.Dock="Right"
                                    Visibility="{Binding Path=HasLauncher,
                                                         RelativeSource={RelativeSource Mode=TemplatedParent},
                                                         Converter={StaticResource BooleanConverter}}">
                                <Button.Template>
                                    <ControlTemplate TargetType="{x:Type Button}">
                                        <ubcr:RibbonChrome Margin="0,0,2,0.7"
                                                           HorizontalContentAlignment="Center"
                                                           VerticalContentAlignment="Bottom"
                                                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                          ResourceId=TransparentBrush}}"
                                                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                           ResourceId=TransparentBrush}}"
                                                           Padding="3,3,3,2"
                                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                                           RenderPressed="{TemplateBinding IsPressed}">
                                            <Image RenderOptions.BitmapScalingMode="Linear"
                                                   RenderOptions.EdgeMode="Aliased"
                                                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                              ResourceId=LauncherButtonImage}}" />
                                        </ubcr:RibbonChrome>
                                    </ControlTemplate>
                                </Button.Template>
                            </Button>
                            <TextBlock Margin="2, 0, 2, 0.7"
                                       VerticalAlignment="Bottom"
                                       DockPanel.Dock="Left"
                                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=DefaultForegroundBrush}}"
                                       Text="{TemplateBinding Header}"
                                       TextAlignment="Center" />
                        </DockPanel>
                    </Grid>
                </Border>
            </Popup>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonGroup}" TargetType="{x:Type ubcr:RibbonGroup}">
        <Setter Property="Margin" Value="2,0,0,0" />
        <Style.Triggers>
            <Trigger Property="Minimized" Value="True">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGroup}, ResourceId=MinimizedRibbonGroupTemplate}}" />
            </Trigger>
            <Trigger Property="Minimized" Value="False">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonGroup}, ResourceId=DefaultRibbonGroupTemplate}}" />
            </Trigger>
        </Style.Triggers>
    </Style>


    <!--  ================================RibbonSplitButton Template and Style==============================================  -->

    <CornerRadius x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=CornerRadiusForSplittButton}">0,0,0,0</CornerRadius>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSplitButton}, ResourceId=SmallRibbonSplitButtonTemplate}" TargetType="{x:Type ubcr:RibbonSplitButton}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="12" />
            </Grid.ColumnDefinitions>

            <Button x:Name="PART_Button"
                    Panel.ZIndex="1"
                    Command="{TemplateBinding Command}"
                    CommandParameter="{TemplateBinding CommandParameter}"
                    CommandTarget="{TemplateBinding CommandTarget}"
                    Content="{TemplateBinding Title}"
                    DataContext="{TemplateBinding Image}"
                    Tag="False">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Border x:Name="Border"
                                    Grid.ColumnSpan="2"
                                    BorderThickness="1" />
                            <Image x:Name="image"
                                   Grid.Column="0"
                                   Width="16"
                                   Height="16"
                                   Margin="4, 0, 0, 0"
                                   HorizontalAlignment="Center"
                                   RenderOptions.BitmapScalingMode="Linear"
                                   RenderOptions.EdgeMode="Aliased"
                                   Source="{TemplateBinding DataContext}"
                                   Stretch="Fill" />
                            <ContentPresenter Grid.Column="1"
                                              Margin="3, 0, 4, 0"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding Content}"
                                              TextBlock.FontSize="11" 
                                              TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBorderBrush}}" />
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBorderBrush}}" />
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                            </Trigger>
                            <Trigger Property="Tag" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                            </Trigger>
                            <DataTrigger Binding="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonSplitButton}}}" Value="True">
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBorderBrush}}" />
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Border x:Name="Border"
                    Grid.ColumnSpan="2"
                    Panel.ZIndex="3"
                    BorderThickness="1" />
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="{Binding Path=DropDownPlacement,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       Mode=OneWay,
                                       NotifyOnSourceUpdated=True}"
                   PlacementTarget="{Binding Path=PlacementTarget,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Mode=OneWay,
                                             NotifyOnSourceUpdated=True}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          MaxHeight="{TemplateBinding MaxDropDownHeight}"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <StackPanel x:Name="PART_DropDownButtonItemsHost"
                                    Margin="1"
                                    FocusVisualStyle="{x:Null}"
                                    Focusable="True"
                                    IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
            <ToggleButton x:Name="PART_Toggle"
                          Grid.Column="1"
                          Panel.ZIndex="2"
                          ClickMode="{TemplateBinding ClickMode}"
                          FocusVisualStyle="{x:Null}"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome Margin="-1, 0, -1, 0"
                                           Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                          ResourceId=TransparentBrush}}"
                                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=TransparentBrush}}"
                                           BorderThickness="1"
                                           CornerRadius="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                            ResourceId=CornerRadiusForSplittButton}}"
                                           Focusable="False"
                                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                    ResourceId=MouseOverBorderBrush}}"
                                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                  ResourceId=PressedBorderBrush}}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <Image x:Name="image"
                                   Width="6"
                                   Height="3"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Focusable="False"
                                   RenderOptions.BitmapScalingMode="HighQuality"
                                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                              ResourceId=ExpandImage}}"
                                   Stretch="Fill" />
                        </ubcr:RibbonChrome>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsDropDownOpen" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                <Setter TargetName="Border" Property="Panel.ZIndex" Value="0" />
                <Setter TargetName="PART_Button" Property="Tag" Value="True" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBorderBrush}}" />
                <Setter TargetName="Border" Property="Panel.ZIndex" Value="0" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSplitButton}, ResourceId=LargeRibbonSplitButtonTemplate}" TargetType="{x:Type ubcr:RibbonSplitButton}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="35" />
                <RowDefinition Height="34" />
            </Grid.RowDefinitions>
            <Button x:Name="PART_Button"
                    Panel.ZIndex="1"
                    Command="{TemplateBinding Command}"
                    CommandParameter="{TemplateBinding CommandParameter}"
                    CommandTarget="{TemplateBinding CommandTarget}"
                    Content="{TemplateBinding Title}"
                    DataContext="{TemplateBinding Image}"
                    Tag="False">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Border x:Name="Border" BorderThickness="1" />
                            <Image Width="32"
                                   Height="32"
                                   HorizontalAlignment="Center"
                                   RenderOptions.BitmapScalingMode="Linear"
                                   RenderOptions.EdgeMode="Aliased"
                                   Source="{TemplateBinding DataContext}"
                                   Stretch="Fill" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBorderBrush}}" />
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                            </Trigger>


                            <Trigger Property="Tag" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Border x:Name="Border"
                    Grid.ColumnSpan="2"
                    Panel.ZIndex="3"
                    BorderThickness="1" />
            <Popup x:Name="PART_DropDownButtonPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent}}"
                   Placement="{Binding Path=DropDownPlacement,
                                       RelativeSource={RelativeSource Mode=TemplatedParent},
                                       Mode=OneWay,
                                       NotifyOnSourceUpdated=True}"
                   PlacementTarget="{Binding Path=PlacementTarget,
                                             RelativeSource={RelativeSource Mode=TemplatedParent},
                                             Mode=OneWay,
                                             NotifyOnSourceUpdated=True}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          MaxHeight="{TemplateBinding MaxDropDownHeight}"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <StackPanel x:Name="PART_DropDownButtonItemsHost"
                                    Margin="1"
                                    FocusVisualStyle="{x:Null}"
                                    Focusable="True"
                                    IsItemsHost="True"
                                    KeyboardNavigation.DirectionalNavigation="Cycle" />
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
            <ToggleButton x:Name="PART_Toggle"
                          Grid.Row="1"
                          Margin="0,-1,0,0"
                          Panel.ZIndex="2"
                          ClickMode="{TemplateBinding ClickMode}"
                          Content="{Binding Path=Title,
                                            RelativeSource={RelativeSource Mode=TemplatedParent},
                                            Mode=TwoWay}"
                          FocusVisualStyle="{x:Null}"
                          IsChecked="{Binding Path=IsDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}">
                <ToggleButton.Template>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <ubcr:RibbonChrome Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                          ResourceId=TransparentBrush}}"
                                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=TransparentBrush}}"
                                           BorderThickness="1"
                                           MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                    ResourceId=MouseOverBackgroundBrush}}"
                                           PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                  ResourceId=PressedBackgroundBrush}}"
                                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                                           RenderPressed="{TemplateBinding IsChecked}">
                            <ubcr:TwoLineText VerticalAlignment="Center"
                                              ImageVisibility="Visible"
                                              Text="{TemplateBinding Content}" />
                        </ubcr:RibbonChrome>
                    </ControlTemplate>
                </ToggleButton.Template>
            </ToggleButton>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsDropDownOpen" Value="True">
                <Setter TargetName="Border" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                <Setter TargetName="Border" Property="Panel.ZIndex" Value="0" />
                <Setter TargetName="PART_Button" Property="Tag" Value="True" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonSplitButton}" TargetType="{x:Type ubcr:RibbonSplitButton}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="PlacementTarget" Value="{Binding RelativeSource={RelativeSource Mode=Self}}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Style.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Height" Value="23" />
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSplitButton}, ResourceId=SmallRibbonSplitButtonTemplate}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
            </Trigger>
            <Trigger Property="Size" Value="Large">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSplitButton}, ResourceId=LargeRibbonSplitButtonTemplate}}" />
                <Setter Property="Height" Value="69" />
                <Setter Property="Width" Value="Auto" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================RibbonToggleButton Template and Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonToggleButton}, ResourceId=SmallRibbonToggleButtonTemplate}" TargetType="{x:Type ubcr:RibbonToggleButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           HorizontalContentAlignment="Left"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsChecked}">
            <Grid Width="{TemplateBinding Width}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Image x:Name="image"
                       Grid.Column="0"
                       Width="16"
                       Height="16"
                       Margin="4, 0, 0, 0"
                       HorizontalAlignment="Center"
                       RenderOptions.BitmapScalingMode="Linear"
                       RenderOptions.EdgeMode="Aliased"
                       Source="{TemplateBinding Image}"
                       Stretch="Fill" />
                <TextBlock x:Name="content"
                           Grid.Column="1"
                           Margin="3, 0, 4, 0"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           FontSize="11"
                           Padding="1,0,1,0"
                           Text="{Binding Path=Title,
                                          RelativeSource={RelativeSource Mode=TemplatedParent}}"
                           TextAlignment="Center"
                           TextTrimming="CharacterEllipsis"
                           TextWrapping="NoWrap" 
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Grid>
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="Title" Value="{x:Null}">
                <Setter Property="Width" Value="24" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonToggleButton}, ResourceId=LargeRibbonToggleButtonTemplate}" TargetType="{x:Type ubcr:RibbonToggleButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsChecked}">
            <Grid Margin="4,0,4,0">
                <Grid.RowDefinitions>
                    <RowDefinition x:Name="row1" />
                    <RowDefinition x:Name="row2" />
                </Grid.RowDefinitions>
                <Image x:Name="image"
                       Width="32"
                       Height="32"
                       Margin="0,0.5,0,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       RenderOptions.BitmapScalingMode="Linear"
                       Source="{TemplateBinding Image}" />
                <ubcr:TwoLineText x:Name="text"
                                  Grid.Row="1"
                                  Margin="3, 0, 5, 0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Top"
                                  FontSize="11"
                                  ImageVisibility="Collapsed"
                                  Text="{TemplateBinding Title}" />
            </Grid>
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonToggleButton}" TargetType="{x:Type ubcr:RibbonToggleButton}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Height" Value="23" />
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonToggleButton}, ResourceId=SmallRibbonToggleButtonTemplate}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
            </Trigger>
            <Trigger Property="Size" Value="Large">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonToggleButton}, ResourceId=LargeRibbonToggleButtonTemplate}}" />
                <Setter Property="Height" Value="69" />
                <Setter Property="Width" Value="Auto" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================RibbonRadioButton Template and Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonRadioButton}, ResourceId=SmallRibbonRadioButtonTemplate}" TargetType="{x:Type ubcr:RibbonRadioButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsChecked}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Image x:Name="PART_SmallRibbonToggleButtonImage"
                       Grid.Column="0"
                       Width="16"
                       Height="16"
                       Margin="3, 0, 2, 0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Source="{TemplateBinding Image}"
                       Stretch="Fill" />
                <TextBlock x:Name="content"
                           Grid.Column="1"
                           Margin="3, 0, 5, 0"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           FontSize="11"
                           Text="{TemplateBinding Title}"
                           TextAlignment="Center"
                           TextTrimming="CharacterEllipsis"
                           TextWrapping="NoWrap" 
                           Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
            </Grid>
        </ubcr:RibbonChrome>
        <ControlTemplate.Triggers>
            <Trigger Property="Title" Value="{x:Null}">
                <Setter TargetName="content" Property="Visibility" Value="Collapsed" />
                <Setter TargetName="PART_SmallRibbonToggleButtonImage" Property="Margin" Value="4,0,4,0" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonRadioButton}, ResourceId=LargeRibbonRadioButtonTemplate}" TargetType="{x:Type ubcr:RibbonRadioButton}">
        <ubcr:RibbonChrome x:Name="PART_RibbonChrome"
                           Background="{TemplateBinding Background}"
                           BorderBrush="{TemplateBinding BorderBrush}"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsChecked}">
            <Grid Margin="4,0,4,0">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Image x:Name="image"
                       Width="32"
                       Height="32"
                       Margin="0,0.5,0,0"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       RenderOptions.BitmapScalingMode="Linear"
                       Source="{TemplateBinding Image}" />
                <ubcr:TwoLineText x:Name="text"
                                  Grid.Row="1"
                                  Margin="3, 0, 5, 0"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Top"
                                  FontSize="11"
                                  ImageVisibility="Collapsed"
                                  Text="{TemplateBinding Title}" />
            </Grid>
        </ubcr:RibbonChrome>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonRadioButton}" TargetType="{x:Type ubcr:RibbonRadioButton}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="Size" Value="Small">
                <Setter Property="Height" Value="23" />
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonRadioButton}, ResourceId=SmallRibbonRadioButtonTemplate}}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Effect">
                    <Setter.Value>
                        <effect:GrayScaleEffect DesaturationFactor="0.0" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
            </Trigger>
            <Trigger Property="Size" Value="Large">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonRadioButton}, ResourceId=LargeRibbonRadioButtonTemplate}}" />
                <Setter Property="Height" Value="69" />
                <Setter Property="Width" Value="Auto" />
            </Trigger>
        </Style.Triggers>
    </Style>


    <!--  ================================RibbonComboBoxItem Template and Style==============================================  -->
    <Style x:Key="{x:Type ubcr:RibbonComboBoxItem}" TargetType="{x:Type ubcr:RibbonComboBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Padding" Value="4,1" />
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle">
            <Setter.Value>
                <Style>
                    <Setter Property="Control.Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Rectangle Margin="2"
                                           SnapsToDevicePixels="True"
                                           Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                      ResourceId=SelectedMenuBackgroundBrush}}"
                                           StrokeDashArray="1 2"
                                           StrokeThickness="1" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ubcr:RibbonComboBoxItem}">
                    <Border x:Name="Bd"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}"
                            SnapsToDevicePixels="True">
                        <ContentPresenter TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GrayBrush}}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsKeyboardFocused" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsKeyboardFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsMouseOver" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsKeyboardFocused" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedTabItemBrush}}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedMenuBackgroundBrush}}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False" />
                                <Condition Property="IsMouseOver" Value="False" />
                                <Condition Property="IsKeyboardFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverMenuBackgroundBrush}}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="False" />
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsKeyboardFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  ================================RibbonComboBox Template and Style==============================================  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox}, ResourceId=EditableComboBoxTemplate}" TargetType="{x:Type ubcr:RibbonComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup"
                   Grid.ColumnSpan="2"
                   Margin="1"
                   AllowsTransparency="True"
                   IsOpen="{Binding IsDropDownOpen,
                                    Mode=TwoWay,
                                    RelativeSource={RelativeSource TemplatedParent}}"
                   Placement="Bottom"
                   PopupAnimation="None"
                   VerticalOffset="-4.2">
                <Border x:Name="DropDownBorder"
                        MinWidth="{Binding ActualWidth,
                                           ElementName=templateRoot}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}"
                        Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize"
                          MinHeight="32.0"
                          VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <ScrollViewer x:Name="DropDownScrollViewer"
                                      Margin="1"
                                      Style="{StaticResource ScrollViewerStyle}">
                            <ItemsPresenter x:Name="ItemsPresenter"
                                            KeyboardNavigation.DirectionalNavigation="Contained"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
            <ToggleButton x:Name="toggleButton"
                          Grid.ColumnSpan="2"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}"
                          IsChecked="{Binding IsDropDownOpen,
                                              Mode=TwoWay,
                                              RelativeSource={RelativeSource TemplatedParent}}">
                <ToggleButton.Style>
                    <Style TargetType="{x:Type ToggleButton}">
                        <Setter Property="IsTabStop" Value="False" />
                        <Setter Property="Focusable" Value="False" />
                        <Setter Property="ClickMode" Value="Press" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                    <Border x:Name="templateRoot"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            SnapsToDevicePixels="True">
                                        <Border x:Name="splitBorder"
                                                Width="15"
                                                HorizontalAlignment="Right"
                                                Background="{TemplateBinding Background}"
                                                BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                ResourceId=TransparentBrush}}"
                                                BorderThickness="1"
                                                SnapsToDevicePixels="True">
                                            <Path x:Name="Arrow"
                                                  Margin="1, -3, 0, 0"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center"
                                                  Data="M0,4 L 6,4 L 3,8 L 0,4"
                                                  Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=DefaultForegroundBrush}}" />
                                        </Border>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}" />
                                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                                            <Setter TargetName="splitBorder" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=MouseOverBackgroundBrush}}" />
                                            <Setter TargetName="splitBorder" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsChecked" Value="True">
                                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}" />
                                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                                            <Setter TargetName="splitBorder" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                                            <Setter TargetName="splitBorder" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=PressedBackgroundBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
                                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
                                            <Setter TargetName="splitBorder" Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                                            <Setter TargetName="splitBorder" Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ToggleButton.Style>
            </ToggleButton>
            <Border x:Name="Border"
                    Margin="{TemplateBinding BorderThickness}"
                    Background="{TemplateBinding Background}">
                <TextBox x:Name="PART_EditableTextBox"
                         Margin="{TemplateBinding Padding}"
                         HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                         VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                         IsReadOnly="{Binding IsReadOnly,
                                              RelativeSource={RelativeSource TemplatedParent}}"
                         Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}">
                    <TextBox.Style>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="OverridesDefaultStyle" Value="True" />
                            <Setter Property="AllowDrop" Value="True" />
                            <Setter Property="MinWidth" Value="0" />
                            <Setter Property="MinHeight" Value="0" />
                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                            <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
                            <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type TextBox}">
                                        <ScrollViewer x:Name="PART_ContentHost"
                                                      Background="Transparent"
                                                      Focusable="False"
                                                      HorizontalScrollBarVisibility="Hidden"
                                                      VerticalScrollBarVisibility="Hidden" />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="Border" Property="Opacity" Value="0.56" />
            </Trigger>
            <Trigger Property="IsKeyboardFocusWithin" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}" />
            </Trigger>
            <Trigger Property="HasItems" Value="False">
                <Setter TargetName="DropDownBorder" Property="Height" Value="95" />
            </Trigger>
            <Trigger Property="IsGrouping" Value="True">
                <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox}, ResourceId=DefaultComboBoxTemplate}" TargetType="{x:Type ubcr:RibbonComboBox}">
        <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
            </Grid.ColumnDefinitions>
            <Popup x:Name="PART_Popup"
                   Grid.ColumnSpan="2"
                   Margin="1"
                   AllowsTransparency="True"
                   IsOpen="{Binding IsDropDownOpen,
                                    Mode=TwoWay,
                                    RelativeSource={RelativeSource TemplatedParent}}"
                   Placement="Bottom"
                   PopupAnimation="None"
                   VerticalOffset="-4.2">
                <Border x:Name="DropDownBorder"
                        MinWidth="{Binding ActualWidth,
                                           ElementName=templateRoot}"
                        MaxHeight="{TemplateBinding MaxDropDownHeight}"
                        Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid x:Name="PART_RibbonDropDownButtonResize" VerticalAlignment="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2"
                                Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                               ResourceId=DropDownBackgroundBrush}}"
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=DropDownShadowEffect}}" />
                        <ScrollViewer x:Name="DropDownScrollViewer"
                                      Margin="1"
                                      Style="{StaticResource ScrollViewerStyle}">
                            <ItemsPresenter x:Name="ItemsPresenter"
                                            KeyboardNavigation.DirectionalNavigation="Contained"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                        <Thumb x:Name="PART_RibbonDropDownButtonThumb"
                               Grid.Row="1"
                               Height="7"
                               Focusable="False"
                               Style="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                         ResourceId=DefaulThumbStyle}}"
                               Visibility="{Binding Path=UserCanResizeDropDown,
                                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                                    Converter={StaticResource ResourceKey=BooleanConverter}}" />
                    </Grid>
                </Border>
            </Popup>
            <ToggleButton x:Name="toggleButton"
                          Grid.ColumnSpan="2"
                          Background="{TemplateBinding Background}"
                          BorderBrush="{TemplateBinding BorderBrush}"
                          BorderThickness="{TemplateBinding BorderThickness}"
                          IsChecked="{Binding IsDropDownOpen,
                                              Mode=TwoWay,
                                              RelativeSource={RelativeSource TemplatedParent}}">
                <ToggleButton.Style>
                    <Style TargetType="{x:Type ToggleButton}">
                        <Setter Property="IsTabStop" Value="False" />
                        <Setter Property="Focusable" Value="False" />
                        <Setter Property="ClickMode" Value="Press" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                    <ubcr:RibbonChrome x:Name="templateRoot"
                                                       Background="{TemplateBinding Background}"
                                                       BorderBrush="{TemplateBinding BorderBrush}"
                                                       BorderThickness="{TemplateBinding BorderThickness}"
                                                       CornerRadius="0"
                                                       InnerBorderCornerRadius="0"
                                                       InnerBorderThickness="0"
                                                       MouseOverBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                                ResourceId=PressedBackgroundBrush}}"
                                                       PressedBorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                                              ResourceId=PressedBackgroundBrush}}"
                                                       RenderMouseOver="{TemplateBinding IsMouseOver}"
                                                       RenderPressed="{TemplateBinding IsChecked}"
                                                       SnapsToDevicePixels="True">
                                        <Border x:Name="splitBorder"
                                                Width="15"
                                                HorizontalAlignment="Right"
                                                SnapsToDevicePixels="True">
                                            <Path x:Name="Arrow"
                                                  Margin="0, -3, 0, 0"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center"
                                                  Data="M0,4 L 6,4 L 3,8 L 0,4"
                                                  Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                           ResourceId=DefaultForegroundBrush}}" />
                                        </Border>
                                    </ubcr:RibbonChrome>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsChecked" Value="True">
                                            <Setter TargetName="Arrow" Property="Fill" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=BlackBrush}}" />
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter TargetName="Arrow" Property="Fill" Value="#FFBFBFBF" />
                                            <Setter TargetName="templateRoot" Property="Background" Value="#FFF0F0F0" />
                                            <Setter TargetName="templateRoot" Property="BorderBrush" Value="#FFD9D9D9" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ToggleButton.Style>
            </ToggleButton>
            <ContentPresenter x:Name="ContentSite"
                              Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              Content="{TemplateBinding SelectionBoxItem}"
                              ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
                              ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                              ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                              IsHitTestVisible="False"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                              TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="HasItems" Value="False">
                <Setter TargetName="PART_RibbonDropDownButtonResize" Property="MinHeight" Value="95" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsGrouping" Value="True" />
                </MultiTrigger.Conditions>
                <Setter Property="ScrollViewer.CanContentScroll" Value="False" />
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:RibbonComboBox}" TargetType="{x:Type ubcr:RibbonComboBox}">
        <Setter Property="FocusVisualStyle">
            <Setter.Value>
                <Style>
                    <Setter Property="Control.Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Rectangle Margin="2"
                                           SnapsToDevicePixels="True"
                                           Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                                           StrokeDashArray="1 2"
                                           StrokeThickness="1" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownBackgroundBrush}}" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=GalleryBorderBrush}}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="5,3,5,3" />
        <Setter Property="ScrollViewer.CanContentScroll" Value="True" />
        <Setter Property="ScrollViewer.PanningMode" Value="Both" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Style.Triggers>
            <Trigger Property="IsEditable" Value="False">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox}, ResourceId=DefaultComboBoxTemplate}}" />
            </Trigger>
            <Trigger Property="IsEditable" Value="True">
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Padding" Value="2" />
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonComboBox}, ResourceId=EditableComboBoxTemplate}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================GroupBox Template and Style==============================================  -->
    <Style x:Key="{x:Type ubcr:GroupBox}" TargetType="{x:Type ubcr:GroupBox}">
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ubcr:GroupBox}">
                    <Border Height="{TemplateBinding Height}"
                            Margin="{TemplateBinding Margin}"
                            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalAlignment}"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            CornerRadius="{TemplateBinding CornerRadius}"
                            Padding="{TemplateBinding Padding}">
                        <StackPanel x:Name="PART_GroupBoxPanel"
                                    IsItemsHost="True"
                                    Orientation="{TemplateBinding Orientation}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--  ================================RibbonSeparator Template and Style==============================================  -->

    <!--  Template for Vertical state  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSeparator}, ResourceId=VerticalSeparatorTemplate}" TargetType="{x:Type ubcr:RibbonSeparator}">
        <Border Width="1"
                Height="{TemplateBinding Height}"
                Margin="{TemplateBinding Margin}"
                HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                VerticalAlignment="{TemplateBinding VerticalAlignment}"
                BorderBrush="{TemplateBinding Background}"
                BorderThickness="1" />
    </ControlTemplate>

    <!--  Template for Horizontal state  -->
    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSeparator}, ResourceId=HorizontalSeparatorTemplate}" TargetType="{x:Type ubcr:RibbonSeparator}">
        <Border Width="{TemplateBinding Width}"
                Height="1"
                Margin="{TemplateBinding Margin}"
                HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                VerticalAlignment="{TemplateBinding VerticalAlignment}"
                BorderBrush="{TemplateBinding Background}"
                BorderThickness="1" />
    </ControlTemplate>


    <Style x:Key="{x:Type ubcr:RibbonSeparator}" TargetType="{x:Type ubcr:RibbonSeparator}">
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=LightGrayBrush}}" />
        <Setter Property="Margin" Value="3, 3.5,3,0" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSeparator}, ResourceId=VerticalSeparatorTemplate}}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonSeparator}, ResourceId=HorizontalSeparatorTemplate}}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--  ================================ContextualItemsHeader Template and Style==============================================  -->
    <Style x:Key="{x:Type ubcr:ContextualItemsHeader}" TargetType="{x:Type ubcr:ContextualItemsHeader}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ubcr:ContextualItemsHeader}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="4" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Border x:Name="upBorder"
                                Grid.Row="0"
                                Background="{TemplateBinding Brush}" />
                        <Border x:Name="downBorder"
                                Grid.Row="1"
                                Background="{TemplateBinding Brush}"
                                Opacity=".1" />
                        <TextBlock x:Name="title"
                                   Grid.Row="1"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Text="{TemplateBinding Title}"
                                   TextTrimming="CharacterEllipsis" 
                                   Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter TargetName="title" Property="Opacity" Value="0" />
                            <Setter TargetName="upBorder" Property="Opacity" Value="0.1" />
                            <Setter Property="Opacity" Value="0.37" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  ================================QAToolbar Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar}, ResourceId=FlatToggleButton}" TargetType="{x:Type ToggleButton}">
        <ubcr:RibbonChrome HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center"
                           Background="{ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                             ResourceId=TransparentBrush}"
                           BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                           ResourceId=TransparentBrush}}"
                           BorderThickness="0"
                           Content="{TemplateBinding Content}"
                           CornerRadius="0"
                           InnerBorderCornerRadius="0"
                           InnerBorderThickness="0"
                           RenderMouseOver="{TemplateBinding IsMouseOver}"
                           RenderPressed="{TemplateBinding IsChecked}" />
    </ControlTemplate>

    <DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:QAToolbar}, ResourceId=CheckableItemTemplate}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="28" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Image Width="7"
                   Height="8"
                   Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                              ResourceId=TickImage}}"
                   Stretch="Fill"
                   Visibility="{Binding Path=IsVisible,
                                        NotifyOnSourceUpdated=True,
                                        Mode=TwoWay,
                                        Converter={StaticResource ResourceKey=BooleanConverter}}" />

            <TextBlock Grid.Column="1"
                       Margin="6,3"
                       VerticalAlignment="Center"
                       Text="{Binding Path=Text,
                                      Mode=TwoWay,
                                      NotifyOnSourceUpdated=True}" 
                       Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DefaultForegroundBrush}}"/>
        </Grid>
    </DataTemplate>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:QAToolbar}, ResourceId=DefaultQAToolbarTemplate}" TargetType="{x:Type ubcr:QAToolbar}">
        <Grid x:Name="PART_Root">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Border x:Name="SeparatorBorder"
                    Height="14"
                    VerticalAlignment="Center"
                    BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                    ResourceId=GrayBrush}}"
                    BorderThickness="1,0,1,0"
                    Visibility="{Binding Path=HasValidItems,
                                         RelativeSource={RelativeSource Mode=TemplatedParent},
                                         Mode=OneWay,
                                         Converter={StaticResource ResourceKey=BooleanConverter}}" />

            <StackPanel x:Name="PART_ItemsHost"
                        Margin="5, 1"
                        Orientation="Horizontal" />

            <Popup x:Name="PART_HiddenPopup"
                   AllowsTransparency="True"
                   IsOpen="{Binding Path=IsHiddenDropDownOpen,
                                    RelativeSource={RelativeSource Mode=TemplatedParent},
                                    Mode=OneWay}"
                   Placement="Bottom"
                   PlacementTarget="{Binding ElementName=PART_HiddenToggle}"
                   PopupAnimation="None"
                   StaysOpen="False"
                   VerticalOffset="-4.2">
                <Border Margin="7"
                        Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                       ResourceId=DropDownBackgroundBrush}}"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                        ResourceId=DropDownBorderBrush}}"
                        BorderThickness="1">
                    <Border.RenderTransform>
                        <TranslateTransform />
                    </Border.RenderTransform>
                    <Grid>
                        <Border Background="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownBackgroundBrush}}" 
                                Effect="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=DropDownShadowEffect}}" />
                        
                        <Grid x:Name="PART_HiddenGrid" Margin="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <StackPanel x:Name="PART_HiddenItemsHost"
                                        Margin="2"
                                        FocusVisualStyle="{x:Null}"
                                        Focusable="True"
                                        KeyboardNavigation.DirectionalNavigation="Cycle"
                                        Orientation="Horizontal" />
                        </Grid>
                    </Grid>
                </Border>
            </Popup>
            <ubcr:RibbonDropDownButton x:Name="PART_DropDownButton"
                                       Grid.Column="1"
                                       Width="12"
                                       Height="20"
                                       ubcr:RibbonHelper.ImageHeight="6"
                                       ubcr:RibbonHelper.ImageWidth="5.5"
                                       Image="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                 ResourceId=QADownArrowImage}}"
                                       Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                    ResourceId=WindowOptionsButtonTemplate}}">
                <ubcr:RibbonGallerySet>
                    <ubcr:RibbonGallery Header="{x:Static res:LocalizationResources.QAToolbarSettingsText}"
                                        ItemTemplate="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:QAToolbar},
                                                                                                         ResourceId=CheckableItemTemplate}}"
                                        ItemsSource="{Binding Path=CheckableItems,
                                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                                              Mode=OneWay,
                                                              NotifyOnSourceUpdated=True}"
                                        ParentMenu="{Binding ElementName=PART_DropDownButton}">
                        <ubcr:RibbonGallery.ItemContainerStyle>
                            <Style TargetType="{x:Type ubcr:RibbonGalleryItem}">
                                <Setter Property="MaxWidth" Value="300" />
                                <Setter Property="Padding" Value="1" />
                                <Setter Property="MinHeight" Value="25" />
                            </Style>
                        </ubcr:RibbonGallery.ItemContainerStyle>
                        <ubcr:RibbonGallery.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel />
                            </ItemsPanelTemplate>
                        </ubcr:RibbonGallery.ItemsPanel>
                    </ubcr:RibbonGallery>
                </ubcr:RibbonGallerySet>
                <ubcr:RibbonSeparator x:Name="separator"
                                      Margin="16,1,1,0"
                                      Orientation="Horizontal" />
                <ubcr:DropDownMenuItem x:Name="PART_PlaceAboveMenuItem"
                                       Header="{x:Static res:LocalizationResources.PlaceQAaboveRibbonBarText}"
                                       Visibility="Collapsed" />
                <ubcr:DropDownMenuItem x:Name="PART_PlaceBelowMenuItem"
                                       Header="{x:Static res:LocalizationResources.PlaceQAunderRibbonBarText}"
                                       Visibility="Collapsed" />
            </ubcr:RibbonDropDownButton>

            <ToggleButton x:Name="PART_HiddenToggle"
                          Grid.Column="1"
                          Width="12"
                          Height="20"
                          ClickMode="Release"
                          IsChecked="{Binding Path=IsHiddenDropDownOpen,
                                              RelativeSource={RelativeSource Mode=TemplatedParent},
                                              Mode=TwoWay}"
                          Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonBar},
                                                                                       ResourceId=FlatToggleButton}}"
                          Visibility="Collapsed">
                <Image Width="7"
                       Height="5"
                       Margin="2,1,0,1"
                       Source="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=TwoRightArrowedImage}}"
                       Stretch="Fill" />
            </ToggleButton>
        </Grid>
        <ControlTemplate.Triggers>
            <!--<DataTrigger Binding="{Binding Path=ApplicationMenu.MenuStyle, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonWindow}}, NotifyOnSourceUpdated=True}" Value="Office2007">
                <Setter Property="Visibility" Value="Visible" TargetName="roundedPath" />
                <Setter Property="Visibility" Value="Visible" TargetName="lineBorder" />
                <Setter Property="Visibility" Value="Visible" TargetName="rightLineBorder" />
                <Setter Property="Visibility" Value="Collapsed" TargetName="SeparatorBorder" />
            </DataTrigger>-->
            <Trigger Property="HasRemovedItems" Value="True">
                <Setter TargetName="PART_HiddenToggle" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsAboveRibbon" Value="True">
                <Setter TargetName="PART_PlaceBelowMenuItem" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsAboveRibbon" Value="False">
                <Setter TargetName="PART_PlaceAboveMenuItem" Property="Visibility" Value="Visible" />
                <Setter TargetName="SeparatorBorder" Property="Visibility" Value="Collapsed" />
                <!--<Setter Property="Visibility" Value="Collapsed" TargetName="roundedPath" />
                <Setter Property="Visibility" Value="Collapsed" TargetName="lineBorder" />
                <Setter Property="Visibility" Value="Collapsed" TargetName="rightLineBorder" />-->
                <Setter Property="Margin" Value="0,0,0,5" />
            </Trigger>
            <Trigger Property="IsAboveRibbon" Value="{x:Null}">
                <Setter TargetName="separator" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsApplicationMenuOpen, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonWindow}}, NotifyOnSourceUpdated=True}" Value="True" />
                    <Condition Binding="{Binding Path=ApplicationMenu.IsDropDownMenu, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonWindow}}, NotifyOnSourceUpdated=True}" Value="False" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Visibility" Value="Collapsed" />
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:QAToolbar}" TargetType="{x:Type ubcr:QAToolbar}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:QAToolbar}, ResourceId=DefaultQAToolbarTemplate}}" />
    </Style>


    <!--  ================================TabControlSelector Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabControlSelector}, ResourceId=DefaultTabControlSelectorTemplate}" TargetType="{x:Type ubcr:TabControlSelector}">
        <ScrollViewer ubcr:ScrollViewerHelper.Attach="True"
                      ubcr:ScrollViewerHelper.ButtonWidth="11"
                      CanContentScroll="True"
                      Template="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonScrollViewer},
                                                                                   ResourceId=SidedScrollViewerTemplate}}">
            <ubcr:RibbonStackPanel AnimatedScroll="False"
                                   FitsToViewport="True"
                                   IsItemsHost="True"
                                   Orientation="Horizontal" />
        </ScrollViewer>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:TabControlSelector}" TargetType="{x:Type ubcr:TabControlSelector}">
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabControlSelector}, ResourceId=DefaultTabControlSelectorTemplate}}" />
    </Style>

    <!--  ================================TabItem Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabItem}, ResourceId=DefaultTabItemTemplate}" TargetType="{x:Type ubcr:TabItem}">
        <Grid>

            <Rectangle x:Name="SeparatorBorder"
                       Height="14"
                       HorizontalAlignment="Right"
                       VerticalAlignment="Center"
                       Stroke="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                  ResourceId=GrayBrush}}"
                       StrokeThickness="1" />

            <ContentPresenter x:Name="headerPresenter"
                              Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              ContentSource="Header"
                              ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                              ContentTemplate="{TemplateBinding HeaderTemplate}"
                              ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                              TextBlock.FontSize="{TemplateBinding FontSize}" />
            <ContentPresenter x:Name="selectedStatedheaderPresenter"
                              Margin="{TemplateBinding Padding}"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              ContentSource="Header"
                              ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                              ContentTemplate="{TemplateBinding HeaderTemplate}"
                              ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                              Opacity="0"
                              TextBlock.FontSize="{TemplateBinding FontSize}"
                              TextBlock.FontWeight="Bold"
                              TextBlock.Foreground="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager},
                                                                                                       ResourceId=TabItemSelectedBrush}}" />
        </Grid>


        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="headerPresenter" Property="TextBlock.Foreground" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TabItemMouseOverBrush}}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="True">
                <Setter TargetName="headerPresenter" Property="Opacity" Value="0" />
                <Setter TargetName="selectedStatedheaderPresenter" Property="Opacity" Value="1" />
            </Trigger>
            <Trigger Property="IsLastItem" Value="true">
                <Setter TargetName="SeparatorBorder" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:TabItem}" TargetType="{x:Type ubcr:TabItem}">

        <Setter Property="FontSize" Value="12" />
        <Setter Property="Padding" Value="15,2" />
        <Setter Property="MinHeight" Value="15" />
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabItem}, ResourceId=DefaultTabItemTemplate}}" />
    </Style>

    <!--  ================================TabControl Template and Style==============================================  -->

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabControl}, ResourceId=DefaultTabControlTemplate}" TargetType="{x:Type ubcr:TabControl}">

        <Border Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                Focusable="False">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <ubcr:TabControlSelector x:Name="PART_TabControlSelector" />

                <Border Grid.Row="1"
                        HorizontalAlignment="Stretch"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">

                    <ContentPresenter Content="{Binding Path=SelectedItem.Content, ElementName=PART_TabControlSelector, NotifyOnSourceUpdated=True}" />

                </Border>
            </Grid>
        </Border>

    </ControlTemplate>

    <Style x:Key="{x:Type ubcr:TabControl}" TargetType="{x:Type ubcr:TabControl}">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=RibbonBarBorderBrush}}" />
        <Setter Property="Background" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}" />
        <Setter Property="Template" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:TabControl}, ResourceId=DefaultTabControlTemplate}}" />
    </Style>

</ResourceDictionary>